Click here to Skip to main content
15,919,245 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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:
C#
(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
C#
GridViewRow row = gvMajor.Rows[e.RowIndex];
                string text=
                ((DropDownList) (row.Cells[3].FindControl(ddlEditTeacher)).SelectedValues;


I have still value "A" not "B" why ?
Posted
Updated 12-Dec-11 8:01am
v5
Comments
Monjurul Habib 4-Dec-11 13:56pm    
clarify your question.

Maybe this will help DataGridDemo[^]
 
Share this answer
 
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900