Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Gridview Buttons Help

  • 31-01-2008 12:28am
    #1
    Registered Users, Registered Users 2 Posts: 325 ✭✭


    Hi

    I'm using c#, VS2005 and MySQL

    I have a gridview with a list of a number of accommodation places coming from the DB.

    Just wondering is it possible for me to put in the Button field thats available and than when one is selected it moves to the page that I want it to.

    example:
    Winter Hotel / 08712345 / Select - choosing select brings it to winter.aspx
    Summer Hotel/ 0986668/ Select - choosing select brings it to summer.aspx


Comments

  • Moderators, Science, Health & Environment Moderators Posts: 9,035 Mod ✭✭✭✭mewso


    Far better to use a hyperlink field that links to a page using the hotel id - view.aspx?hotelid={0}
    [SIZE=2][COLOR=#0000ff]<[/COLOR][/SIZE][SIZE=2][COLOR=#800000]asp[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]:[/COLOR][/SIZE][SIZE=2][COLOR=#800000]HyperLinkField[/COLOR][/SIZE] [SIZE=2][COLOR=#ff0000]DataNavigateUrlFields[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]="hotelid"[/COLOR][/SIZE] [SIZE=2][COLOR=#ff0000]DataNavigateUrlFormatString[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]="~/view.aspx?hotelid={0}"[/COLOR][/SIZE] [SIZE=2][COLOR=#ff0000]Text[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]="Select"[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]/>
    [/COLOR][/SIZE]
    

    Now the view.aspx page can use the hotelid to display the relevent data and you only need one page to do this instead of a seperate page for each hotel.


  • Registered Users, Registered Users 2 Posts: 325 ✭✭doyler442


    Cheers for the help.

    I had a hyperlink there alright, I was just wondering if it was possible with a button.

    Thanks


  • Registered Users, Registered Users 2 Posts: 515 ✭✭✭NeverSayDie


    You can use command buttons for this kind of thing if you want, basically, the button passes parameters to the event handler on the postback. This tutorial has a brief explanation, Google/MSDN will have more;
    http://www.eggheadcafe.com/articles/20011210.asp

    Or you can use a LinkButton control - it's rendered as a hyperlink, but exposes the same functionality as the Button.

    As musician points out, you're better having one display page that can display any hotel instead of multiple pages for different hotels, given that this is data-driven.


  • Moderators, Society & Culture Moderators Posts: 9,689 Mod ✭✭✭✭stevenmu


    You can use the default select button and the write a trigger for the onselectionchanged event for the gridview. In that you can put the code to redirect to whatever page suits you.


  • Moderators, Science, Health & Environment Moderators Posts: 9,035 Mod ✭✭✭✭mewso


    doyler442 wrote: »
    Cheers for the help.

    I had a hyperlink there alright, I was just wondering if it was possible with a button.

    Thanks

    It's trickier to use a button. For example you could just put in a select button but then in your code behind you need to access the hotelid using datakeys or another convoluted method and this is forcing the user to post back to the same page before being redirected to the page they want. Unecessary unless you want to run other code before passing them onto the other page but again anything you might want to do could be done on the new page when it loads anyway. If you want a button then how about just using css to style the link like one.


  • Advertisement
Advertisement