I have problem with edit date in gridview.When I edit gridview i want update one of cell. So enter new value in this cell, and problem is that i don't have any idea how can i download this new value because than i write:
(textbox)(gridview.Rows(e.RowIndex).Cells[2].Control[0]).Text.ToString()
I download old value not new.
Can someone help me ?
12-12-2011
This link didn't help i still have this problem.
I change text box to dropdown list but i have still this problem.
Now i have something like tihs :
<Columns>
<asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
<asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False"
SortExpression="ID" />
<asp:TemplateField>
<ItemTemplate>
<asp:Label ID="Teacher_name" runat="server" Text='<%# Eval("Teacher_name") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:DropDownList ID="ddlEditTeacher" runat="server"
DataSourceID="SqlDataSource1" DataTextField="Teacher_name"
DataValueField="Teacher_name"
></asp:DropDownList>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:DiaryConnectionString %>"
SelectCommand="SELECT Teachers.name+' '+Teachers.surname AS[Teacher_name] FROM Teachers">
</asp:SqlDataSource>
</EditItemTemplate>
</asp:TemplateField>
but still when i edit item i can use new select values. For example if drop down list have to values "A" and "B". Now in grid view is value "A". When i want change this value, i click on edit and select in drop down list value "B" but in function gv_RowUpdating when i write
GridViewRow row = gvMajor.Rows[e.RowIndex];
string text=
((DropDownList) (row.Cells[3].FindControl(ddlEditTeacher)).SelectedValues;
I have still value "A" not "B" why ?