Hi, friends i have a datagrid bound a hypercolumn

<asp:DataGrid ID="menu" AutoGenerateColumns="False" Runat="server">
<Columns>
<asp:HyperLinkColumn   DataTextField="OPT_DESC" DataNavigateUrlField="OPT_LINK" 	DataNavigateUrlFormatString="{0}"/>
</Columns>
</asp:DataGrid>

basically what i want to do is, that i want to insert into the database the users that click some links. so how can i make a clickevent in this case thanks.

1. Set the button's CommandName property to a string that identifies its function, such as "Insert" or "copy".

2. Create a method for the ItemCommand event of the control. In the method, do the following:

a. Check the CommandName property of the event-argument object to see what string was passed.

b. Perform the appropriate logic for the button that the user clicked.

private void DataGrid_ItemCommand(object source, 
    DataGridCommandEventArgs e)
{
    if (e.CommandName == "AddToCart")
    {
        // Add code here to insert details into database.
        // Use the value of e.Item.ItemIndex to find the data row
        // in the data source.
    }
}

In fact that is the problem that the hyperlinkcolumn does not have the CommandName property.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.