如何在gridview中为整行设置超链接 [英] How to set a hyperlink for entire row in gridview
问题描述
亲爱的朋友们,
我已经从数据库中检索到GridView的记录,我需要在gridview中为整行设置一个超链接。但我尝试过bellow格式,它只使用了一列,请任何人帮助我。
< asp:GridView ID =GridView1runat =server>
< ;列>< asp:TemplateField HeaderText =SName
< itemtemplate>
<%#Eval(SName)%>
< asp:BoundField DataField =SNameHeaderText =学生姓名/>
< asp:BoundField DataField =SMarksHeaderText =学生成绩/ >
< asp:BoundField DataField =SDOBHeaderText =学生DOB/>
Dear Friends,
I have retrieved records from database to GridView, I need to set a hyperlink for entire row in gridview. But I have tried bellow format it has working with only one column, please any one help me.
<asp:GridView ID="GridView1" runat="server">
<columns><asp:TemplateField HeaderText="SName"
<itemtemplate>
<%#Eval("SName")%>
<asp:BoundField DataField="SName" HeaderText="Student Name" />
<asp:BoundField DataField="SMarks" HeaderText="Student Marks" />
<asp:BoundField DataField="SDOB" HeaderText="Student DOB" />
推荐答案
检查以下网址
http://www.ablemods.com/blog/post/2012/08/06/ASPNet-Gridview-how-to-make-entire-row- a-link.aspx [ ^ ]
希望有所帮助。
Check the following url
http://www.ablemods.com/blog/post/2012/08/06/ASPNet-Gridview-how-to-make-entire-row-a-link.aspx[^]
Hope it helps.
检查这个...
使整个行可以在gridview中点击 [ ^ ]
查看下一个请求。
http://stackoverflow.com/questions/17311757 / on-click-the-hyperlink-inside-gridview-it-should-redirect-to-a-page-and- [ ^ ]
希望th会帮助你。
干杯
Hi,
check this...
Making an entire row clickable in a gridview[^]
Check this for your next req.
http://stackoverflow.com/questions/17311757/on-clicking-the-hyperlink-inside-gridview-it-should-redirect-to-a-page-and-and[^]
Hope this will help you.
Cheers
也许你可以为GridView控件的每一列添加一个LinkButton。
标记
Perhaps you can add a LinkButton to each column of the GridView control.
Markup
<asp:gridview id="GridView" xmlns:asp="#unknown">
Font-Names="Arial" Font-Size="0.75em"
CellPadding="5" CellSpacing="0"
ForeColor="#333" AutoGenerateColumns="true"
onrowdatabound="GridView_RowDataBound"
runat="server">
<HeaderStyle BackColor="#989898" ForeColor="white" />
</asp:gridview>
稍后将其与每个绑定行。
Later bind it with each row.
protected void GridView_RowDataBound(object sender, System.Web.UI.WebControls.GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
LinkButton lb = new LinkButton();
lb.ID = "lbBooks";
lb.Text = "Select";
e.Row.Cells[3].Controls.Add(lb);
}
}
你可以通过这个文章,可能有帮助。
以编程方式将LinkButton添加到GridView
这篇关于如何在gridview中为整行设置超链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!