0

Hi All,

I Got a issue when i restore the tag property value in datagrid. In my form having two text box and a button called add. i can able to add text box value into datagrid using bindsource class. PFB

EmpList se= new EmpList(textBox1.Text, textBox2.Text);
bindingSource1.Add(new EmpDetail(se.one, se.Two));
this.dataGridView1.Tag = selectedEmp;
dataGridView1.DataSource = bindingSource1;

Assume my grid having two rows and cols with some values. My problem is i cant restote the first row value by using Tag property when clicking ceelcontent click event. Always i am getting the (selectedEmp)values which has added recently. PFB

selectedEmp = (EmpList)dataGridView1.SelectedCells[0].DataGridView.Tag;

i need to get the exact row value(What i select on cell content row) using tag property and store them wrt textboxes.
Please tell me what i am doing wrong. TIA.

2
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by vigneshkbv
0

In the first snippet it seems like you are setting the .Tag member of the entire datagrid, not the individual cells/rows.

In the second snippet you are accessing the first index of the selected cells, then trying to get the tag member out of it's parent gridview.

I would try providing a meaningful tag to either the row or the cells as you add them, rather than using a tag member of the entire gridview.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.