0
我的asp.net 3.5應用程序[C#]中有gridview。它看起來像這樣:從asp.net中的代碼更新gridview
<asp:GridView CssClass="grid_table" ID="GridView1" AllowPaging="true" PageSize="10"
AutoGenerateEditButton="true" ShowHeader="true"
AutoGenerateDeleteButton="true" DataKeyNames="studentId" runat="server"
OnRowEditing="GridView1_RowEditing"
OnRowCancelingEdit="GridView1_RowCancelingEdit"
OnRowDeleting="GridView1_RowDeleting"
OnRowUpdating="GridView1_RowUpdating"
onpageindexchanging="GridView1_PageIndexChanging" onrowupdated="GridView1_RowUpdated"
>
<EmptyDataTemplate>
<asp:Label ID="lblNoRecord" runat="server" Text="No Record Found" ForeColor="Red"> </asp:Label>
</EmptyDataTemplate>
</asp:GridView>
現在,在RowUpdating事件,我寫了下面的代碼:
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
int mytext = Convert.ToInt16(GridView1.Rows[e.RowIndex].Cells[1].Text);
string cConatiner = GridView1.Rows[e.RowIndex].Cells[4].Text;
}
在此,會將myText是給我正確的值,即第1列,但是當我正在改變單元格值爲1,2,3,4,5,6我變空了。我是不是做得不對?
請幫幫我。
在此先感謝。
請幫忙,我無法找到解決方案 – Zerotoinfinity 2010-05-29 10:13:25
因爲我有你的cConatiner總是空的。這是你的問題嗎?你檢查從DB /(其他來源)獲取的數據嗎? – chapluck 2010-05-29 10:29:35
我從數據集綁定我的gridview,gridview顯示9列和16行,我無法獲得單元格的值。 – Zerotoinfinity 2010-05-29 10:34:40