我有这个带有 AutoGenerateEditButton="true" 的网格视图:
<asp:GridView ID="myGridview" runat="server"
ShowFooter="True"
AutoGenerateDeleteButton="true" AutoGenerateEditButton="true"
AutoGenerateColumns="False" AllowSorting="True" DataKeyNames="id" DataSourceID="odsVolumeSearch" OnRowUpdating="myGridview_RowUpdating">
<Columns>
<asp:BoundField DataField="id" HeaderText="id" Visible="false" InsertVisible="False" ReadOnly="True" SortExpression="id" />
<asp:BoundField DataField="Date" HeaderText="date" SortExpression="Date" ReadOnly="True" />
<asp:BoundField DataField="Items" HeaderText="Items" SortExpression="Items" />
</Columns>
</asp:GridView>
这是我的对象数据源:
<asp:ObjectDataSource ID="myOds" runat="server"
DeleteMethod="myDeleteMethod" SelectMethod="mySelectMethod"
TypeName="TheirLocation.sqlDataLayer" UpdateMethod="myUpdateMethod">
<DeleteParameters>
<asp:Parameter Name="id" Type="Int32" />
</DeleteParameters>
<SelectParameters>
<asp:Parameter Name="fromDate" Type="DateTime"/>
<asp:Parameter Name="toDate" Type="DateTime"/>
</SelectParameters>
<UpdateParameters>
<asp:Parameter Name="id" Type="Int32" />
<asp:Parameter Name="volume" Type="Int32" />
</UpdateParameters>
</asp:ObjectDataSource>
这里的混乱是我的更新事件处理程序:
protected void gvVolumeList_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
GridViewRow row = gvVolumeList.Rows[e.RowIndex];
String debugString = ((TextBox)(row.Cells[1].Controls[0])).Text;
Response.Write("<script>alert('" + debugString + "');</script>");
}
我只是想从我的文本框中获取值以显示在警报中,但我无法修复它。我已经尝试了各种方法并且疯狂地用谷歌搜索,但我无法获得价值
编辑
我认为问题是我从单元格中获取文本,而不是单元格内的文本框。虽然还是不知道该怎么办