Click here to Skip to main content
15,922,533 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi
i want to get the value of the row from the gridview in my webpage , my grid has three fields whith type tempeletfield .

when i click on the url field get the value of the url in string .
Posted
Comments
MickyTh 3-Apr-13 6:03am    
Can you explain ur problem wth code?

You can find the Texboxes and get the data from it.
Try this:
C#
protected void Gridview1_SelectedIndexChanged(object sender, EventArgs e)
{
   string s1 = ((TextBox)Gridview1.SelectedRow.FindControl("TextBox1")).Text;
   string s2 = ((TextBox)Gridview1.SelectedRow.FindControl("TextBox2")).Text;
   string s3 = ((TextBox)Gridview1.SelectedRow.FindControl("TextBox3")).Text;
}



--Amit
 
Share this answer
 
Comments
Darsh_Basha 3-Apr-13 6:13am    
@_Amy

sorry , but i don't understand your answer
_Amy 3-Apr-13 6:16am    
Create a SelectedIndexChanged event for your GridView and try finding the TextBoxes in your code.
Darsh_Basha 3-Apr-13 6:35am    
@_Amy
this is not my question , i asked to press on the gridview then get the value that selected or pressed .
_Amy 3-Apr-13 8:00am    
To select the gridview row you should have SelectedIndexChanged with a LinkButton or Button. Then only you can get the data. See the links given by Ridoy in solution 2.
Add DataKeyNames property of gridview to the list and the following value of the particular row can be retrieved by the following code...

C#
int index = int.Parse(e.CommandArgument.ToString());
string value = grdView.DataKeys[index].Value.ToString().Trim();
 
Share this answer
 
v2

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