GridVieew中更新数据库数据的问题
我的GridView控件中什么控件也没放就是把数据库中的数据显示到控件中。当想更新数据库中数据时,用后代代码
string str1 = GridView1.Rows[e.RowIndex].Cells[0].Text.Trim();
string str2 = GridView1.Rows[e.RowIndex].Cells[1].Text.Trim();
string str3 = GridView1.Rows[e.RowIndex].Cells[2].Text.Trim();
string str4 = GridView1.Rows[e.RowIndex].Cells[3].Text.Trim();
DataBaseConnection connection1 = new DataBaseConnection();
connection1.DataUpdateRoomCategory(str1, str2, str3, str4);
GridView1.DataBind();
执行时为什么str1,str2,str3,str4的值都为空值??
这是前台代码:
<asp:GridView ID="GridView1" runat="server" BackColor="Gray"
BorderColor="#336666" BorderStyle="Double" BorderWidth="3px" CellPadding="4"
GridLines="Horizontal" AllowPaging="True" AllowSorting="True"
AutoGenerateColumns="False" DataSourceID="SqlDataSource2"
style="position:absolute; top: 12px; left: 13px; height: 260px; width: 786px;"
PageSize="6" DataKeyNames="RoomId" RowStyle-HorizontalAlign="Center"
onrowupdating="GridView1_RowUpdating">
<FooterStyle BackColor="White" ForeColor="#333333" />
<RowStyle BackColor="White" ForeColor="#333333" HorizontalAlign="Center" />
<Columns>
<asp:BoundField DataField="RoomId" HeaderText="Id" SortExpression="Id" >
<ItemStyle VerticalAlign="Middle" />
</asp:BoundField>
<asp:BoundField DataField="RoomPrice" HeaderText="房间价格" />
<asp:BoundField DataField="RoomBed" HeaderText="房间床位" />
<asp:BoundField DataField="RoomArea" HeaderText="房间面积" />
<asp:CommandField HeaderText="插入" ShowEditButton="True" />
<asp:TemplateField HeaderText="删除"><ItemTemplate>
<asp:LinkButton ID="LinkButton1" runat="server" CommandName="Delete" OnClientClick="return confirm('您真的要删除该记录吗?');">删除</asp:LinkButton></ItemTemplate></asp:TemplateField>
</Columns>
<PagerStyle BackColor="#336666" ForeColor="White" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#339966" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#336666" Font-Bold="True" ForeColor="White" />
</asp:GridView>
是什么原因当修改GridView中的数据时为什么str1,str2,str3,str4的值为空""值?????