?
Solved

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

Posted on 2009-04-23
14
Medium Priority
?
335 Views
Last Modified: 2013-11-07
hi,

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

Thanks
0
Comment
Question by:Shiva_Kumar
14 Comments
 
LVL 22

Expert Comment

by:prairiedog
ID: 24225838
Could you please elaborate your question a little more?
0
 
LVL 14

Expert Comment

by:amar31282
ID: 24226564
please explain your question little more
0
 
LVL 3

Expert Comment

by:bizjosh
ID: 24227279
You need to pass the cell value into the button's code parameter of value=''

Cheers.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:Shiva_Kumar
ID: 24227840
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
 
LVL 22

Expert Comment

by:prairiedog
ID: 24227976
0
 
LVL 22

Expert Comment

by:prairiedog
ID: 24227990
The whole idea here is to first find the Select button, then you can change its Text property to whatever you wish.
0
 

Author Comment

by:Shiva_Kumar
ID: 24228546
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
 
LVL 22

Expert Comment

by:prairiedog
ID: 24228665
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
 

Author Comment

by:Shiva_Kumar
ID: 24228782
I use VB
0
 
LVL 22

Expert Comment

by:prairiedog
ID: 24228817
Can you try my comment then and let me know if it works for you?
0
 

Author Comment

by:Shiva_Kumar
ID: 24229255
Nope, it didn't work for me.  

any alternate suggestion?
0
 
LVL 22

Expert Comment

by:prairiedog
ID: 24229375
What do you mean "it didn't work"? You got an error?
0
 

Accepted Solution

by:
Shiva_Kumar earned 0 total points
ID: 24232624
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
 

Author Comment

by:Shiva_Kumar
ID: 24232670
Hi,

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

Thanks
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

755 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question