C# ASP.NETC中的数据网格视图超链接#

C# ASP.NETC中的数据网格视图超链接#,c#,asp.net,datagridview,C#,Asp.net,Datagridview,您好,我正在使用DataGridView,通过映射数据库中的URL,我在Hyperlinkfield中给出了该URL(例如:DataGridView中将显示10-20个链接),如果特定的人单击特定的链接,那么它必须通过增加数据库中该特定URL的计数列重定向到该特定URL 注意:iam在模板设计模式下使用datagridview。您可以在row命令事件中执行此操作 使用您希望提供的url创建一个动态单击使用命令参数,并在Gridview onrowcommand事件中执行操作 <asp:Gr

您好,我正在使用DataGridView,通过映射数据库中的URL,我在Hyperlinkfield中给出了该URL(例如:DataGridView中将显示10-20个链接),如果特定的人单击特定的链接,那么它必须通过增加数据库中该特定URL的计数列重定向到该特定URL


注意:iam在模板设计模式下使用datagridview。

您可以在row命令事件中执行此操作


使用您希望提供的url创建一个动态单击使用命令参数,并在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("");
    }
  }

受保护的void GridView1_row命令(对象发送方,GridViewCommandEventArgs e)
{
如果(e.CommandName==“btnUpdate”)
{
int index=Convert.ToInt32(e.CommandArgument);
//基于LinkID从数据库获取当前单击次数。
int icount;
//增加计数
//再次更新数据库并获取链接。
//重定向到链接
响应。重定向(“”);
}
}