Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 3.5 > ASP.NET 3.5 Basics
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 3.5 Basics If you are new to ASP or ASP.NET programming with version 3.5, this is the forum to begin asking questions. Please also see the Visual Web Developer 2008 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 3.5 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old July 19th, 2010, 11:16 AM
Authorized User
Points: 343, Level: 6
Points: 343, Level: 6 Points: 343, Level: 6 Points: 343, Level: 6
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2009
Posts: 74
Thanks: 5
Thanked 0 Times in 0 Posts
Default I need help on making an entire grid row selectable and passing id thru a querystring

Hello every one, I need help... I have a gridview control and I want to make the entire rows selectable, that is all the colums in a row,I do not want to use a select link or button.not only that, I want to pass the value of the id field of the selected row in a query string. I know how to do this if I were to use a select link in each row,but this it isn't what I want. Thank you
  #2 (permalink)  
Old July 19th, 2010, 11:59 AM
Friend of Wrox
Points: 1,749, Level: 16
Points: 1,749, Level: 16 Points: 1,749, Level: 16 Points: 1,749, Level: 16
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2007
Location: San Diego, CA, USA.
Posts: 477
Thanks: 10
Thanked 19 Times in 18 Posts
Default

Quote:
Originally Posted by ysfkay View Post
Hello every one, I need help... I have a gridview control and I want to make the entire rows selectable, that is all the colums in a row,I do not want to use a select link or button.not only that, I want to pass the value of the id field of the selected row in a query string. I know how to do this if I were to use a select link in each row,but this it isn't what I want. Thank you
I think I can help though I'm not sure how "I want to make the entire rows selectable, that is all the colums in a row" is different from selecting a row. So let me back up a step and maybe it will take care of your question or you can provide more details.

When you create a GridView, it's because you want to display and / or edit information, so you've got the right tool for that job. Now, it sounds like you want to be able to 1) select the row and 2) pass it's ID into the query string so you can operate on the row on another page.

I think all you need to do is grab the (this is from memory mind you) Item_Selected(??) event handler and execute something like this...

Code:
Grab the id of the row from the GridView

Create a string for the URL and populate the query parameter from the variable which holds the ID

Call a response.redirect to the variable which holds the URL
Then you can pick the query parameter up on the redirected page and proceed from there.
__________________
-------------------------

Whatever you can do or dream you can, begin it. Boldness has genius, power and magic in it. Begin it now.
-Johann von Goethe

When Two Hearts Race... Both Win.
-Dove Chocolate Wrapper

Chroniclemaster1, Founder of www.EarthChronicle.com
A Growing History of our Planet, by our Planet, for our Planet.
  #3 (permalink)  
Old July 19th, 2010, 01:24 PM
Authorized User
Points: 343, Level: 6
Points: 343, Level: 6 Points: 343, Level: 6 Points: 343, Level: 6
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2009
Posts: 74
Thanks: 5
Thanked 0 Times in 0 Posts
Default Thanks

Yes I understand what u mean, infact I did that but using a select hyperlink in the itemtemplate of the grid like this
<asp:TemplateField>
<ItemTemplate>

<asp:HyperLink NavigateUrl='<%#"~/General/Generic.aspx?MembershipId="+Eval("MembershipId")%>' ID="HyperLink1" runat="server">Select</asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>

However, this is not what I want, I want to make the row selectable and not a hyperlink in the row, then I want to pass the Id field to another page..

Please I would also need a sample code for clearity. I tried using the RowDataBound event of the gridview to make the row selectable (see code below), but I got an error saying
“The name ClientScript” does not exist in the current context and secondly
If this method works, I do not understand how I could pass the id in query string since there isnt any field like the hyperlink this time: please see the code below, Thanks.

protected void GridViewMembers_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes["onmouseover"] = "this.style.cursor='hand';this.style.textDecoratio n='underline';";
e.Row.Attributes["onmouseout"] = "this.style.textDecoration='none';";

e.Row.Attributes["onclick"] = ClientScript.GetPostBackClientHyperlink(this.GridViewMembers, "Select$" + e.Row.RowIndex);
}

}

Last edited by ysfkay; July 19th, 2010 at 01:30 PM..
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
$data[0][$row->parentid]['children'][$row->id] = $row->name mehdymahmood BOOK: Professional CodeIgniter ISBN: 978-0-470-28245-8 1 February 2nd, 2010 02:19 AM
Passing data via querystring LanceRoss Beginning VB 6 3 July 25th, 2008 12:20 PM
Zoom to row on gridview using querystring??? Jhawker81 ASP.NET 2.0 Basics 0 March 12th, 2007 10:03 PM
copy entire row stealthdevil Access VBA 3 December 1st, 2006 11:39 AM
onClick change bgcolor of entire row Pallav Javascript How-To 2 October 21st, 2004 12:35 AM



All times are GMT -4. The time now is 05:09 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.