• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 318
  • 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
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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