ASP.NET - Getting value from label in grid - Asked By Thiyagu S on 14-Sep-10 06:16 AM

Hi friends....

       I am using label to bind the value in grid...
       I want to get the label value and i want to merge them in another cell(moving up/down)
       So how can i get the label value from gridcell and how can i assign them to another cell....

       How to solve this problem
Sagar P replied to Thiyagu S on 14-Sep-10 06:23 AM
You can get the value of label like this;

Label lbl= GridView1.Rows[index].FindControl("lblID") as Label;
string lblText = lbl.Text;

Anurag replied to Thiyagu S on 14-Sep-10 06:49 AM
just assign the labels's text like this
gridview1.Rows[i].Cells[j].Text  += Label1.Text;
or if u have that label in a gridview's cell then
use find control(Label1) and then follow the same procedure.
Thiyagu S replied to Sagar P on 14-Sep-10 07:13 AM

Hi friend...

     Thanks... Its working
Goniey N (Mr. G) replied to Thiyagu S on 14-Sep-10 09:40 AM
-- Try Below Also :

1.// Here It Will Move The Label Value Of Second Row To The First Row Label...
2.((Label)GridView1.Rows[1].FindControl("Gridlbl")).Text = ((Label)GridView1.Rows[2].FindControl("Gridlbl")).Text;

-- Hope This Will Help You..