public partial class Form2 : Form
{
BindingNavigator bnnav = new BindingNavigator(true);
BindingSource bsource = new BindingSource();
TextBox txt = new TextBox();
public Form2()
{
InitializeComponent();
this.bnnav.BindingSource=this.bsource;
this.bnnav.Dock = DockStyle.Top;
this.Controls.Add(this.bnnav);
this.txt.Dock = DockStyle.Bottom;
this.Controls.Add(txt);
this.Size = new Size(800,200);
this.Load += new EventHandler(Form2_Load);
}
private void Form2_Load(object sender, EventArgs e)
{
string constrg = "Data Source=srikanth;Initial Catalog=worktoworker;Integrated Security=True";
SqlConnection con = new SqlConnection(constrg);
SqlDataAdapter da = new SqlDataAdapter("Select * from customer",con);
DataSet ds = new DataSet("Work2Work customers");
ds.Tables.Add("customer");
da.Fill(ds.Tables["customer"]);
bsource.DataSource = ds.Tables["customer"];
txt.DataBindings.Add(new Binding("Text",bsource,"Name",true));
}
}
For this line i am getting exception which is
This causes two bindings in the collection to bind to the same property.
Parameter name: binding
how can i resolve it