views:

326

answers:

1

Hi Experts,

I have gridview in my asp.net 3.5 application [C#]. Which looks like this:

<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>

Now, In rowUpdating event, I am writing the below code:

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;
}

In this, myText is giving me the correct value, i.e. of the 1st column but when I am changing the cell value to 1,2,3,4,5,6 I am getting empty.

Am I doing it incorrectly ?

Please help me.

Thanks in advance.

A: 

I don't see where you are setting a cell's value with the value of mytext. I am going to assume you are try to set Cell[4]'s value in the code below:

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;
}

If Cell[4] isn't want cell you're setting, change appropriately.

TheGeekYouNeed