Connecting DataBase To Dynamically Generated Hyperlinks

Here is a quick sample demonstrating how to dynamically link data to hyperlinks.


<table>
            <tr>
                <td style="width: 100px">
                    <asp:GridView ID="GdViewCategories" runat="server" BackColor="White" BorderColor="#CCCCCC"
                        BorderStyle="None"  headerstyle-backcolor="maroon"   headerstyle-forecolor="khaki"
                        BorderWidth="1px" CellPadding="3" Height="232px" OnRowDataBound="GdViewCategories_RowDataBound"
                        Width="303px" AutoGenerateColumns="False" >
              </td>
           </tr>
</table>




using
System;

using System.Data;

using System.Configuration;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;

using BLL;

public partial class _Default : System.Web.UI.Page

{

BLLGridView BllObj = new BLLGridView();

protected void Page_Load(object sender, EventArgs e)

{

GdViewCategories.DataSource = BllObj.GetCategories();

GdViewCategories.DataBind();

}

protected void GdViewCategories_RowDataBound(object sender, GridViewRowEventArgs e)

{

e.Row.Cells[0].Visible = false;

}

}

By ramya salva   Popularity  (1047 Views)