Hi, friends i have a datagrid bound a hypercolumn

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

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.

8 Years
Discussion Span
Last Post by jbisono

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.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.