Click here to Skip to main content
15,886,664 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to give hyperlink in datagridview,

any help would be appreciated.
Posted

 
Share this answer
 
Comments
Prasad_Kulkarni 23-May-12 9:35am    
Glad it helps!
I assume you must have used DataGridViewLinkColumn to display your HyperLinks. In that case, in order to repspond to User Clicks on HyperLinks, you must handle the CellContentClick event. This event is distinct from the CellClick and CellMouseClick events, which occur when a user clicks anywhere in a cell.

for asp.net gridview

with in a gridview write like
C#
<asp:gridview id="gvDeleteUsers" runat="server" width="321px" xmlns:asp="#unknown">
 AutoGenerateColumns="False" onrowdeleting="gvDeleteUsers_RowDeleting"
 BackColor="White" BorderColor="#CC9966" BorderStyle="None" BorderWidth="1px"
 CellPadding="4" Font-Names="Verdana" Font-Size="Small">

 <rowstyle backcolor="White" forecolor="#330099" horizontalalign="Center">
 VerticalAlign="Middle" />
 <columns>
  <asp:templatefield headertext="UserName">
 <itemtemplate>
 <asp:linkbutton id="TypenameLabel" runat="server" cssclass="style_homefirst" text="<%# Eval("Text") %>" />
 </itemtemplate>
 <asp:commandfield showdeletebutton="true" />
 </columns>
 <footerstyle backcolor="#FFFFCC" forecolor="#330099" />
 <pagerstyle backcolor="#FFFFCC" forecolor="#330099" horizontalalign="Center" />
 <selectedrowstyle backcolor="#FFCC66" font-bold="True" forecolor="#663399">
 HorizontalAlign="Center" VerticalAlign="Middle" />
 <headerstyle backcolor="#990000" font-bold="True" forecolor="#FFFFCC" />

 </selectedrowstyle></rowstyle>

here in Eval write ur database field name for which u want to create link button.
 
Share this answer
 
v3
XML
<asp:TemplateField>
<HeaderTemplate>
Req.No
</HeaderTemplate>
<ItemTemplate>
     <asp:TextBox ID="txtReqNo" MaxLength="4" Width="40px" runat="server"> </asp:TextBox>
     <asp:HyperLink ID="hi" runat="server" Text='<%#Eval("YourValue") %>' NavigateUrl="~/pms/Store/change_password.aspx"></asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>
 
Share this answer
 
v2

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