Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

retrieve value from datagrid row using c#

Status
Not open for further replies.

logi2000

Programmer
Jun 17, 2003
221
CR
hi, i have a datagrid with template columns.
i also have a select link button column, i want to obtain the value of the first column of the selected row. i am using c#. i have try something like

dgcontrol.SelectedIndex.Rows[0].Text byt it does not return the value of the row. or it returns a "" value.

what would be the best way to retrieve the value from the column ?
 
Well, if your in a template column and you have entered an asp:TextBox or the like, you have to do this...

CType(dgControl.Items(0).FindControl("ControlName"),TextBox).Text

or

CType(dgControl.Items(0).FindControl("ControlName"),DropDownList).SelectedItem.Text
 
Try this for selected row -

CType(dgControl.Items(dgcontrol.SelectedIndex).FindControl("ControlName"),TextBox).Text
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top