However, I'm getting out range error in run time. Attached is my code snipet. The error happens at
"var sam = ((TextBox)(editRow.Cells.Controls)).Text;"
I think that the code is taking the row that is being edited (editRow is correct when I examine the property). Cell 0 I think is the Edit button on my grid, it shows as the first column. So cells is the column that I want. Examine the property of Cells show it has count of 6 and that is correct, 1st one is the Edit button generated by gridview control however, the error is with Controls being out of range.
In the aspx file, the 1st cell is a boundfield, code as below
<asp:BoundField DataField ="sAMAccountName" HeaderText="User ID" ReadOnly="True" HeaderStyle-HorizontalAlign="Center" HeaderStyle-VerticalAlign="Middle"></asp:BoundField>
Appreciate help here to fix the problem. Thank you.
I add editRow.Cells to the Watch and there is a cells object. But I don't know how to expand to see where is the Controls because that's where I get the error. I'm attaching the screen shot for this too.
further examination by adding to the Watch panel, I found the error is caused because Cells.Controlls.count is 0. I'm also attaching a screen shot for this. Why is that so? It does display the data that it's bound to. How can I fix this?
Thank you. snipet.txt grid-err-1.png grid-err-2.png
Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.