Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 315
  • Last Modified:

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
0
GRChandrashekar
Asked:
GRChandrashekar
  • 6
  • 6
1 Solution
 
Meir RivkinFull stack Software EngineerCommented:
that should work:
dgridtitle.SelectedRows(0).Cells("DESCRIPTION").Value.ToString()

Open in new window


FYI, make sure the column name is case sensitive.
0
 
GRChandrashekarAuthor Commented:
Tried that also
0
 
Meir RivkinFull stack Software EngineerCommented:
what are you getting?
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
GRChandrashekarAuthor Commented:
Column named Titleid cannot be found.
Parameter name: columnName

I copied from griddata property name and pasted so that name is right still error
0
 
Meir RivkinFull stack Software EngineerCommented:
when u debug your code, before this line, put dgv.Columns in the Watch window and see if the collection contains "Titleid"
0
 
GRChandrashekarAuthor Commented:
It is there
0
 
Meir RivkinFull stack Software EngineerCommented:
you need the Name property of the Column not the header text or the bound property.
0
 
GRChandrashekarAuthor Commented:
Yes I have taken Name property of the Column
0
 
GRChandrashekarAuthor Commented:
This works :
dgridtitle.SelectedRows(0).Cells("TitleidDataGridViewTextBoxColumn").Value.ToString()

But is this the way ?
0
 
Meir RivkinFull stack Software EngineerCommented:
where TitleidDataGridViewTextBoxColumn came from?
0
 
GRChandrashekarAuthor Commented:
copied from grid view design-name
0
 
Meir RivkinFull stack Software EngineerCommented:
great, as long as its working
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 6
  • 6
Tackle projects and never again get stuck behind a technical roadblock.
Join Now