Click here to Skip to main content
15,896,606 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi goodevening every body,
i am Raghu i have no idea on how to bind data from gridview to textboxes, in my webpage i have four textboxes, one gridview and one button(name=save) when i click the save button 1)textboxes data should be save into database abd also display into the gridview.
2) when i click any row into the gridview the row data should be bind to textboxes with in the page. please help me
Posted

1 solution

Hi,
If you know the row number of the grid view than you can easily bind the text boxes...


There might be two situations.. Either you are having the select link to select the values in gridview or you simply want to show the particular row's data in the text boxes..

SITUATION 1:
Go to he rowCommand event of the gridview and find the and match the command name and find the row of the gridview on which event is generated...
then simply write the following coding:
C#
txtID.Text=gvData.Rows[e.RowIndex].Cells["ID"].ToString();


SITUATION 2:
simply write the coding like this:
C#
txtID.Text=gvData.Rows[10].Cells["ID"].ToString();
  //In case if you are trying to fetch the id of 10th row



Try it.. All the best...
Accept the answer if you like it...
 
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