Hi Lynn,
Based on my understanding, you want to add a column with is hyperlink class
in your datagrid control.
Asp.net DataGrid control has a build-in HyperLinkColumn, you can just
leverage it to display a column of hyperlinks in datagrid, Like this:
private void Page_Load(object sender, System.EventArgs e)
{
if(!this.IsPostBack)
{
DataSet ds=new DataSet ();
SqlDataAdapter adapter=new SqlDataAdapter("select * from
jobs","server=localhost;database=pubs;uid=sa;pwd=");
adapter.Fill(ds);
DataGrid1.DataSource=ds;
DataGrid1.DataBind();
}
}
//Html View Code
<asp
ataGrid id="DataGrid1" style="Z-INDEX: 101; LEFT: 96px; POSITION:
absolute; TOP: 64px" runat="server"
Width="400px" Height="232px">
<Columns>
<asp:HyperLinkColumn DataTextField="job_desc"
HeaderText="HyperLinkColumn"
NavigateUrl="
http://msdn.microsoft.com"></asp:HyperLinkColumn>
</Columns>
</asp
ataGrid>
It should work as you expected.
Surely, you can just TemplateColumn to add HyperLink control in that
column, this will give more control on the behavior, like this:
<asp
ataGrid id="DataGrid1" style="Z-INDEX: 101; LEFT: 96px; POSITION:
absolute; TOP: 64px" runat="server"
Width="400px" Height="232px">
<Columns>
<asp:TemplateColumn>
<ItemTemplate>
<asp:HyperLink ID="hl" Runat="server"
Text='<%#DataBinder.Eval(Container.DataItem, "job_desc")%>'
NavigateUrl="
http://msdn.microsoft.com"></asp:HyperLink>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp
ataGrid>
================================================
Please apply my suggestion above and let me know if it helps resolve your
problem.
Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.
Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! -
www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.