Click here to Skip to main content
15,891,184 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi friends
I am trying to read the column value of gridview read only columns.but it does not get the value from column.
the following is my code in rowupdate event in asp.net gridview

My code is

C#
protected void branchgrid_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            comp.ADMISSIONNUMBER = Convert.ToInt32((TextBox)studacgrid.Rows[e.RowIndex].FindControl("AdmissionNumber"));
            //comp.ADMISSIONNUMBER = Convert.ToInt32(studacgrid.Rows[e.RowIndex].Cells[1]
            comp.MEDIUM =Convert.ToString ((TextBox)studacgrid.Rows[e.RowIndex].FindControl("Medium"));
            comp.CLASSNAME =Convert.ToString ((TextBox)studacgrid.Rows[e.RowIndex].FindControl("Class"));
            comp.ACADAMICYEAR = Convert.ToString((TextBox)studacgrid.Rows[e.RowIndex].FindControl("Academicyear"));
            comp.SECTIONNAME = Convert.ToChar(((TextBox)studacgrid.Rows[e.RowIndex].Cells[7].Controls[0]).Text.ToString());
        }
Posted
Updated 22-Aug-13 1:04am
v2

There's Text property.
C#
comp.ADMISSIONNUMBER = Convert.ToInt32(studacgrid.Rows[e.RowIndex].Cells[1].Text);
 
Share this answer
 
Comments
baskaran chellasamy 22-Aug-13 7:21am    
I cannot able to get value from gridview using Text property.because first four columns are read only column.
ErBhati 22-Aug-13 7:23am    
use
Convert.ToInt32(studacgrid.Rows[e.RowIndex].Cells["column name"].Text)
ErBhati 22-Aug-13 7:24am    
use

Convert.ToInt32(studacgrid.Rows[e.RowIndex].Cells[1].Text)
C#
void ContactsGrid_RowDeleting(Object sender, GridViewDeleteEventArgs e)
{
    ContactsGrid.Rows[e.RowIndex].Cells[0];
}


or

C#
protected void gv_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
    textbox hf = (textbox ) gv.Rows[e.RowIndex].Cells[0].FindControl("hf");
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900