Selecting a data on a gridview

Last post 07-05-2009 2:48 PM by PeteNet. 1 replies.

Sort Posts:

  • Selecting a data on a gridview

    07-05-2009, 1:52 PM
    • Member
      point Member
    • luigivibal
    • Member since 06-12-2009, 2:59 PM
    • Posts 16

    Hi! I have a gridview wherein datas are displayed and the first column has a link. Now i want to select a data on that gridview by clicking that databound field, pass the value of that link and display data on the other page. How can i do this?

  • Re: Selecting a data on a gridview

    07-05-2009, 2:48 PM
    Answer
    • All-Star
      27,884 point All-Star
    • PeteNet
    • Member since 01-21-2009, 6:15 PM
    • Posts 3,959
    you can use a HyperLinkField like this:

       <asp:hyperlinkfield headertext="Title"
    datatextfield="title"
    datanavigateurlfields="title_id"
    datanavigateurlformatstring="details_title.aspx?titleid={0}" />

    here's an example: http://authors.aspalliance.com/aspxtreme/webforms/controls/addinghyperlinkfieldstogridview.aspx

    so, now on details_title.aspx you could parse the querystring for the titleid and load appropriate data

    public partial class Test: System.Web.UI.Page
    {
    int TitleID = 0;
            protected void Page_Load(object sender, EventArgs e)
            {

                if (Request["titleid"] != null)
                {
                    TitleID = Convert.ToInt32(Request["titleid"]);
    //get data with that TitleID etc
                }
            }
    }



    Regards,
    Peter
Page 1 of 1 (2 items)