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
Shiva_KumarAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

Cheers.
0
Fundamentals of JavaScript

Learn the fundamentals of the popular programming language JavaScript so that you can explore the realm of web development.

Shiva_KumarAuthor Commented:
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
0
prairiedogCommented:
The whole idea here is to first find the Select button, then you can change its Text property to whatever you wish.
0
Shiva_KumarAuthor Commented:
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


0
prairiedogCommented:
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#?
0
Shiva_KumarAuthor Commented:
I use VB
0
prairiedogCommented:
Can you try my comment then and let me know if it works for you?
0
Shiva_KumarAuthor Commented:
Nope, it didn't work for me.  

any alternate suggestion?
0
prairiedogCommented:
What do you mean "it didn't work"? You got an error?
0
Shiva_KumarAuthor Commented:
hi,

I have tried a different approach to change the select button text to match the row text.  I have added the following code to the RowDataBound
=========================================================================
Dim row As GridViewRow = e.Row
        Dim selectCell As TableCell = row.Cells(0)
        If (selectCell.Controls.Count > 0) Then

            Dim selectControl As LinkButton = selectCell.Controls(0)
            If Not IsDBNull(selectControl) Then

                selectControl.Text = e.Row.Cells(1).Text
              End If
        End If
==============================================================================
It is now showing the select box as the row text but it shows in this way

          <Row Name>
abc         abc
xyz         xyz
123         123

I have added the line
e.Row.Cells(1).Visible = False

to disable the second column... but it still shows the <Row Name> and the place holder for the second coumn still exists.

How can I remove the complete second row and have only select button column shown.  Please provide the steps with vb code(i am new to asp.net)

Thanks

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Shiva_KumarAuthor Commented:
Hi,

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

Thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.