开发者

how to add a hyper link in a gridview

I have a gridview control and I would like the field Title to be a hyperlink and execute a stored procedure when clicked. Can anyone assist me in this?

Does this code look right?

<Columns>
    <asp:TemplateField>
        <ItemTemplate>
            <asp:HyperLink ID="hpTitle" runat="开发者_如何学Pythonserver" Text='<%# Bind("Title") %>' NavigateUrl='<%# Bind("SelectBook") %>'></asp:HyperLink>
        </ItemTemplate>
    </asp:TemplateField>
    <asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False" ReadOnly="True" SortExpression="ID" />
    <asp:BoundField DataField="Publisher" HeaderText="Publisher" SortExpression="Publisher" />
    <asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title" />
</Columns>


<asp:TemplateField>
                <ItemTemplate>
                <asp:HyperLink id="hplink" runat="server" Text='<%# Bind("columnname")%>' NavigateUrl='<%# Bind("columnname")%>'></asp:HyperLink>
                </ItemTemplate>
            </asp:TemplateField>

On NavigateUrl, you can redirect to any page and on page_load you can call any stored procedure by using SQlCommand Object.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜