GridView编辑-在文本框/下拉列表中输入后的新值 [英] GridView edit - new values after wirte in textbox/dropdownlist
问题描述
我在gridview中的编辑日期有问题.当我编辑gridview时,我想更新单元格之一.因此,在此单元格中输入新值,问题是我不知道如何下载此新值,因为比我这样写道:
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()
我下载的是旧值而不是新值.
有人可以帮我吗?
2011年12月12日
此链接没有帮助我仍然有此问题.
我将文本框更改为下拉列表,但仍然存在此问题.
现在我有了类似tihs的东西:
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>
但是当我编辑项目时,我仍然可以使用新的选择值.例如,如果下拉列表必须具有值"A"和"B".现在在网格视图中是值"A".当我想更改此值时,单击编辑",然后在下拉列表值"B"中选择,但在编写gbr_RowUpdating函数时写入
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;
我仍然值"A"而不是"B"为什么?
I have still value "A" not "B" why ?
推荐答案
ConnectionStrings:DiaryConnectionString%> SelectCommand ="SELECT Teachers.name +''''+ Teachers.surname AS [Teacher_name] FROM Teachers"> </asp:SqlDataSource> </EditItemTemplate> </asp:TemplateField>
ConnectionStrings:DiaryConnectionString %>" SelectCommand="SELECT Teachers.name+'' ''+Teachers.surname AS[Teacher_name] FROM Teachers"> </asp:SqlDataSource> </EditItemTemplate> </asp:TemplateField>
但是当我编辑项目时,我仍然可以使用新的选择值.例如,如果下拉列表必须具有值"A"和"B".现在在网格视图中是值"A".当我想更改此值时,单击编辑",然后在下拉列表值"B"中选择,但在编写gbr_RowUpdating函数时写入
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;
我仍然值"A"而不是"B",为什么?
I have still value "A" not "B" why ?
也许这会帮助^ ]
尝试
GridView.RowEditing事件 [全功能可编辑GridView控件 [在ASP.NET中编辑单个GridView单元格 [ ^ ]
Try
GridView.RowEditing Event[^]
Full-featured Editable GridView Control[^]
Edit Individual GridView Cells in ASP.NET[^]
这篇关于GridView编辑-在文本框/下拉列表中输入后的新值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!