views:

50

answers:

1

Okay I do not even know where to begin when it comes to this I am continuing from this question: http://stackoverflow.com/questions/2664029/linq-to-sql-statement-issue

Where I searched multiple columns in a table and returned my values in a datagrid, Ive done basic formatting on the grid but am unable to decipher how I would go about getting each row to link to another page?

        using (TiamoDataContext context = new TiamoDataContext())
    {
        var search = from p in context.UserProfile1s
                     where p.DanceType == UserSearchString ||
                           p.Username == UserSearchString ||
                           p.Occupation == UserSearchString ||
                           p.LookingFor == UserSearchString ||
                           p.Location == UserSearchString ||
                           p.LastName == UserSearchString ||
                           p.Gender == UserSearchString ||
                           p.FirstName == UserSearchString ||
                           p.DanceType == UserSearchString ||
                           p.DanceSong == UserSearchString ||
                           p.DanceLevel == UserSearchString ||
                           p.DanceIcon == UserSearchString ||
                           p.BodyBuild == UserSearchString ||
                           p.Age.ToString() == UserSearchString ||
                           p.AboutMe == UserSearchString
                     select new
                     {
                         Username = p.Username,
                         Firstname = p.FirstName,
                         Lastname = p.LastName,
                         Location = p.Location,
                         DanceType = p.DanceType
                     };

        UserSearchGrid.DataSource = search;
        UserSearchGrid.DataBind();


    }

And

              <asp:GridView ID="UserSearchGrid" runat="server" CellPadding="4" 
                    ForeColor="#333333" GridLines="None" Height="93px" Width="702px">
                    <RowStyle BackColor="#EFF3FB" />
                    <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                    <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
                    <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
                    <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                    <EditRowStyle BackColor="#2461BF" />
                    <AlternatingRowStyle BackColor="White" />
                </asp:GridView>

Thanks I know you guys have helped me loads today I am just enjoying this too much its fuuun....

A: 

You could use a hyperlinkField just set the AutogenerateColumns property from your grid and set one of the column to hyperlinkField here is an example

<asp:gridview id="OrdersGridView" 
    datasourceid="OrdersSqlDataSource" 
    autogeneratecolumns="false"
    runat="server">

    <columns>

      <asp:boundfield datafield="OrderID" 
        headertext="OrderID"/>
      <asp:boundfield datafield="CustomerID" 
        headertext="Customer ID"/>
      <asp:boundfield datafield="OrderDate" 
        headertext="Order Date"
        dataformatstring="{0:d}" />
      <asp:hyperlinkfield text="Details..."
        navigateurl="~\details.aspx"            
        headertext="Order Details"
        target="_blank" />

    </columns>

  </asp:gridview>
alejandrobog
I did something similar using a button field thank you for your answer it is valid :)
Anicho