Click here to Skip to main content
15,171,664 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to display category names in the form of a table. Next to the category name column, I want to have a column containing buttons. On clicking this button, it should redirect to another page showing more details about that specific category.

Could you help me out?

What I have tried:

protected void Page_Load(object sender, EventArgs e)
   SqlConnection conn = new SqlConnection(@"Data Source=NASHIISHEENA;Initial Catalog=HousekeepingPortal_DB;Integrated Security=True");
   SqlCommand cmd = new SqlCommand("Select Cat_Name from tblCategory",conn);
   SqlDataReader dr = cmd.ExecuteReader();

   GridView1.DataSource = dr;
Updated 25-Feb-18 19:40pm

1 solution

refer this sample

<asp:GridView runat="server" ID="GridView1" AutoGenerateColumns="false">
              <asp:BoundField HeaderText="Category Name " DataField="Cat_Name" />
              <asp:HyperLinkField DataTextField="Cat_Name" DataNavigateUrlFields="Cat_Name" DataNavigateUrlFormatString="~/Details.aspx?category={0}"
                  HeaderText="Details" ItemStyle-Width="150" />

In details page:
public partial class Details : System.Web.UI.Page
       protected void Page_Load(object sender, EventArgs e)
          string categroy =  Request.QueryString["category"];
           // you code to populate the details


Reference Hpyer link column in gridivew

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900