如何在GridView中设置链接我的数据字段列之一 [英] How to set link one of my datafield column in gridview
本文介绍了如何在GridView中设置链接我的数据字段列之一的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的项目中有一个 Gridview.我有一列pur_no,它是BoundField,它显示数据库中的数据.我希望该字段类似于链接字段,该怎么做,请帮助我.当我单击否时,它会重定向到另一页,如何操作,请帮助我.
我想关注
pur_no
1
2
3
4
I have a Gridview in my project. I have a column pur_no which is BoundField, which is displays datas from database. I want that field is like link field, How to do it,Please help me. For when I click that no, it is redirect to another page, How to do it, Please help me.
I want like following
pur_no
1
2
3
4
推荐答案
试试这个
Hi ,
Try this
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<a href= "<%# Eval("address") %>" id="a1" > Click here</a>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
if (!IsPostBack)
{
using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["testConnectionString"].ConnectionString))
{
con.Open();
using (SqlCommand cmd = new SqlCommand("select * from test1", con))
{
DataTable dt = new DataTable();
SqlDataAdapter adpt = new SqlDataAdapter(cmd);
adpt.Fill(dt);
GridView1.DataSource = dt;
GridView1.DataBind();
}
}
}
最好的问候
M.Mitwalli
Best Regards
M.Mitwalli
请参阅:
http://www.csharpaspnetarticles.com/2009/04/linkbutton-gridview-querystring.html [^ ]
Refer this:
http://www.csharpaspnetarticles.com/2009/04/linkbutton-gridview-querystring.html[^]
您必须对此线程有一个了解:
datagridview中的超链接 [
You must have a look on this thread:
HyperLink in datagridview[^]
Here this question was solved, You will defiantly get some help from it.
这篇关于如何在GridView中设置链接我的数据字段列之一的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文