<asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False" EmptyDataText="Sevkiyat Bulunamadı"
class="table table-striped table-bordered table-condensed"
AllowPaging="True"
OnPageIndexChanged="GridView1_PageIndexChanged"
OnPageIndexChanging="GridView1_PageIndexChanging"
OnRowDataBound="RowDataBound"
OnRowCommand="GridView1_RowCommand"
AllowSorting="True"
DataSourceID="SqlDataSource1"
OnSelectedIndexChanged="GridView1_SelectedIndexChanged">
<Columns>
<asp:TemplateField>
<HeaderTemplate>
<asp:CheckBox ID="checkAll" runat="server" onclick="checkAll(this);" />
Teklif İste
</HeaderTemplate>
<ItemTemplate>
<asp:CheckBox ID="CheckBox1" runat="server" onclick="Check_Click(this)" />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="yetkiliad" ItemStyle-CssClass="yetkiliad" HeaderText="yetkiliad" SortExpression="yetkiliad" />
<asp:BoundField DataField="yetkilisoyad" ItemStyle-CssClass="yetkilisoyad" HeaderText="yetkilisoyad" SortExpression="yetkilisoyad" />
<asp:BoundField DataField="firmaismi" ItemStyle-CssClass="firmaismi" HeaderText="firmaismi" SortExpression="firmaismi" />
<asp:BoundField DataField="telefon" ItemStyle-CssClass="telefon" HeaderText="telefon" SortExpression="telefon" />
<asp:BoundField DataField="adres" ItemStyle-CssClass="adres" HeaderText="adres" SortExpression="adres" />
<asp:BoundField DataField="mail" ItemStyle-CssClass="mail" HeaderText="mail" SortExpression="mail" />
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton Text="View" ID="lnkView" runat="server" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
<RowStyle VerticalAlign="Middle" />
</asp:GridView>
我有这样的代码。我无法找到如何在每行单击视图按钮时重定向。我的意思是当我点击第二行的视图时,它应该被重定向到第二行的相关链接。你能帮帮我吗
答案 0 :(得分:1)
无需在LinkButton
内创建asp:TemplateField
。只需使用asp:HyperLinkField
这样的
<asp:HyperLinkField Text="View"
DataNavigateUrlFields="firmaname"
DataNavigateUrlFormatString="~/{0}.aspx" />
答案 1 :(得分:0)
<asp:LinkButton ID="lnkView" runat="server" OnClick="lnkView_Click" CommandArgument='<%#Eval("Id") %>View</asp:LinkButton>
protected void lnkView_Click(object sender, EventArgs e)
{
int Id = (sender as LinkButton).CommandArgument;
Response.Redirect("Foo.aspx?Id=" + Id);
}