Question

Summary:

I want to to create a templateField resulting from a database after calling gridview.databind to have it function as a linkbutton doing something when pressing it.

In other words, I want to bind a templateField with data at runtime.

Was it helpful?

Solution

 <asp:GridView ID="GridView1" runat="server">
    <Columns>
        <asp:TemplateField>
            <ItemTemplate>
                <asp:LinkButton ID="LinkButton1" runat="server" OnClick="lclick">Buy</asp:LinkButton>
            </ItemTemplate>
        </asp:TemplateField>
    </Columns>
</asp:GridView>


protected void lclick(object sender, EventArgs e)
{
    // your function
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top