Hi Everybody,
I am a c# beginner level. I have two problem. The problem is as follow.
First is. I want to know gridview's row selected with my value.Like that, when i click the button open a form1 that has a gridview, I will give a parameter like that ID 3. In gridview there are many row with ID as 1, 2, 3, 4, 5. When the form1 is opened, I want to auto select the row in gridview that has id 3.
Second is. In that form1, there are two textbox. That are ID and Sr. I can fill the data to that textboxs first time open form1 ID is 3 and Sr is 2.But when I double click the another row in gridview with ID 4 and Sr 1. When it fill the data to textbox, I get error message.
Error message is "This causes two bindings in collection to bind to the same property.Parameter name: binding".My code sample is as follow.
private void Form1_Load(object sender, EventArgs e)
{
loadData(myParameterID);
}
private void LoadData(myParameterID)
{
bsData = new BindingSource();
dtData = new DataTable();
dtData = UtilityAccess.GetDataTable("Select ID, Sr From tbl1 Where ID = " + myParameterID , fillOptions.normal);
bsData.DataSource = dtData;
this.txtID.DataBindings.Add("Text", bsData, "ID", true);
this.txtSr.DataBindings.Add("Text", bsData, "Sr";, true);
}
private void dgv_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e)
{
LoadData(myParameterID);
}