Click here to Skip to main content
15,887,596 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have added a column to my datatable
dt.Columns.Add("Date")

and assigned this datatable to my gridview i.e
grddates.DataSource = dt;
          Session.Add("dt", dt);
          grddates.DataBind();


Now I want to get the value of that label on GridviewRowDataBound.
How I can do that?
Is there any other way of doing this?

What I have tried:

I have added a column to my datatable <pre>dt.Columns.Add("Date")

and assigned this datatable to my gridview i.e
grddates.DataSource = dt;
          Session.Add("dt", dt);
          grddates.DataBind();


Now I want to get the value of that label on GridviewRowDataBound.
How I can do that?
Is there any other way of doing this?
Posted
Updated 17-Jul-17 20:36pm

1 solution

if(e.Row.RowType == DataControlRowType.DataRow)
    {
       
        int coulumnIndex = 0;
        var value=  e.Row.Cells[1].Text ;// for reading bound field columns
        var value1 = (e.Row.FindControl("label1") as Label).Text;// for reading template columns 

    }
 
Share this answer
 
Comments
Member 10549697 18-Jul-17 2:37am    
Hi Karthik, Thanks a lot.
Karthik_Mahalingam 18-Jul-17 2:41am    
welcome

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