Link to home
Start Free TrialLog in
Avatar of Shiva_Kumar
Shiva_Kumar

asked on

how to change the select button value to the row selected in Gridview

hi,

how do I change the select button value to the corresponding row/cell value in a Gridview

Thanks
Avatar of prairiedog
prairiedog
Flag of United States of America image

Could you please elaborate your question a little more?
please explain your question little more
You need to pass the cell value into the button's code parameter of value=''

Cheers.
Avatar of Shiva_Kumar
Shiva_Kumar

ASKER

Hi bizjosh

Could you please explain me in detail how do i do this.

By default the button is a link and the default text it shows is "Select"

Thanks,
Shiva
The whole idea here is to first find the Select button, then you can change its Text property to whatever you wish.
Ok... Let me explain what I am trying to here:

i have a gridview which populates on sigle column from the database like this.

abc
xyz
123

i wanted to have these values clickable so that i can populate another gridview next to it taking the SelectedIndexValue as one of the parameter to run another sql query to popluate the gridveiw2.

In order to achieve this i have added a commandfield select, so after adding this it shows something like this:

Select   abc
Select   xyz
Select   123

Now what i am to do is to have the "Select" to replace with the actual row values and the same time it should be clickable so that i can popluate the second gridview.

Please let me know if this is a wrong approach.  If yes, the please let me know is there any alternate way of doing this.

Thanks,
Shiva


The better way to do is define DataKeyNames="YourPrimaryKeyField", then in the SelectedRowIndexChanged event handler, get the primary key as follows to run another query:
Dim id As Integer
id = Integer.Parse(Me.GridView1.SelectedDataKey.Value.ToString())
Do you use VB or C#?
I use VB
Can you try my comment then and let me know if it works for you?
Nope, it didn't work for me.  

any alternate suggestion?
What do you mean "it didn't work"? You got an error?
ASKER CERTIFIED SOLUTION
Avatar of Shiva_Kumar
Shiva_Kumar

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
Hi,

i was able to fix the second issue by adding the headertext = "false" in the girdview property.

Thanks