0

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.

3
  • Please help, I am Unable to find the solution Commented May 29, 2010 at 10:13
  • As i got your cConatiner is always empty. Is it Your problem? Did you check data fetched from DB/(other source)? Commented May 29, 2010 at 10:29
  • I am binding my gridview from dataset, and gridview is showing 9 columns and 16 rows, I am unable to get the value of cells. Commented May 29, 2010 at 10:34

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.