Link to home
Start Free TrialLog in
Avatar of GRChandrashekar
GRChandrashekarFlag for India

asked on

Load textfrom from gridview selected row

I am trying to load textbox from selected keydown of gridview

tried both ways as under but no luck

bxtitleid.Text = dgridtitle.Item("TitleID", dgridtitle.CurrentRow.Index).Value
            tbxdescription.Text = dgridtitle.SelectedRows(0).Cells("DESCRIPTION").Value.ToString()


it was column name not valid
Avatar of Meir Rivkin
Meir Rivkin
Flag of Israel image

that should work:
dgridtitle.SelectedRows(0).Cells("DESCRIPTION").Value.ToString()

Open in new window


FYI, make sure the column name is case sensitive.
Avatar of GRChandrashekar

ASKER

Tried that also
what are you getting?
Column named Titleid cannot be found.
Parameter name: columnName

I copied from griddata property name and pasted so that name is right still error
when u debug your code, before this line, put dgv.Columns in the Watch window and see if the collection contains "Titleid"
It is there
ASKER CERTIFIED SOLUTION
Avatar of Meir Rivkin
Meir Rivkin
Flag of Israel image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Yes I have taken Name property of the Column
This works :
dgridtitle.SelectedRows(0).Cells("TitleidDataGridViewTextBoxColumn").Value.ToString()

But is this the way ?
where TitleidDataGridViewTextBoxColumn came from?
copied from grid view design-name
great, as long as its working