【发布时间】:2012-04-23 14:27:29
【问题描述】:
您好,我正在使用 DataGridView,方法是映射我在 Hyperlinkfield 中给出的数据库中的 URL(例如:datagridview 中将显示 10-20 个链接)如果特定人单击特定链接,则它必须通过增加该特定 URL 的数据库中的 Count 列来重定向到该特定 URL。
注意:我在模板设计模式下使用datagridview。
【问题讨论】:
标签: c# asp.net datagridview
您好,我正在使用 DataGridView,方法是映射我在 Hyperlinkfield 中给出的数据库中的 URL(例如:datagridview 中将显示 10-20 个链接)如果特定人单击特定链接,则它必须通过增加该特定 URL 的数据库中的 Count 列来重定向到该特定 URL。
注意:我在模板设计模式下使用datagridview。
【问题讨论】:
标签: c# asp.net datagridview
你可以在行命令事件中做到这一点
使用您希望提供的网址创建动态点击
【讨论】:
使用 CommandArgument 并在 Gridview onrowcommand 事件中做你的事情。
<asp:GridView ID="GridView1" OnRowCommand="GridView1_RowCommand" runat="server">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton ID="btnUpdate" runat="server" CommandArgument='<%#Eval("LinkID")%>' CommandName="btnUpdate" Text='<%#Eval("LinkDisplayText")%>'>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
protected void GridView1_RowCommand(Object sender, GridViewCommandEventArgs e)
{
if(e.CommandName=="btnUpdate")
{
int index = Convert.ToInt32(e.CommandArgument);
//based on LinkID get the current click count from database.
int icount;
//increment the count
//update the database once again and get the link as well.
//redirect to the link
Response.Redirect("");
}
}
【讨论】: