Introduction:-
In this article , I have explained how to convert
gridview column into hyperlink.
Design
the page like this:-
<asp:GridView ID="GridView1"
runat="server"
AutoGenerateColumns="False">
<Columns>
<asp:HyperLinkField
runat="server"
DataTextField="name"
DataNavigateUrlFields="id"
DataNavigateUrlFormatString="~/Details.aspx?id{0}" HeaderText="Name"/>
<asp:BoundField DataField="Emailid" HeaderText="EmailId" />
</Columns>
</asp:GridView>
//Details.aspx page is another page
on which you redirect to see details according to id.
Bind GridView:-
protected void Page_Load(object
sender, EventArgs e)
{
if (!this.IsPostBack)
{
DataTable
dt = new DataTable();
dt.Columns.AddRange(new DataColumn[4]
{ new DataColumn("id"), new
DataColumn("name"),
new DataColumn("Emailid"), new
DataColumn("mobileno")
});
dt.Rows.Add(1,"Sushil Kumar","sushil@gmail.com","9874563258");
dt.Rows.Add(2,"Muthu Kumar","muthu@gmail.com","5896574125");
dt.Rows.Add(3,"Ashutosh Ojha","ashu@gmail.com","8745214789");
dt.Rows.Add(4,"Sanjay wadhawa","sanjay@gmail.com","9852475635");
GridView1.DataSource = dt;
GridView1.DataBind();
}
}
No comments:
Post a Comment
Note: only a member of this blog may post a comment.