0

asp.net 3.5アプリケーション[C#]に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に変更すると、空になります。

私はそれを間違ってやっていますか?

私を助けてください。

前もって感謝します。

4

1 に答える 1

1

mytextの値でセルの値を設定している場所がわかりません。以下のコードでCell[4]の値を設定しようとしていると仮定します。

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;

    GridView1.Rows[e.RowIndex].Cells[4].Text = mytext;
}

Cell [4]が設定中のセルを必要としない場合は、適切に変更してください。

于 2010-05-29T20:54:29.217 に答える