Link to home
Start Free TrialLog in
Avatar of Webboy2008
Webboy2008

asked on

asp.net c#

When View Details link is clicked, I want to raise some command..
like response.write "hello"....as an example.
How to do it?

<asp:GridView ID="CustomersView" DataSourceID="Customers"
AutoGenerateColumns="False" AllowSorting="true" AllowPaging="true" PageSize="10"
DataKeyNames="Scheduleid" EmptyDataText="No transaction" runat="server"    
        CellPadding="3" GridLines="Horizontal" 
        >
<HeaderStyle BackColor="Maroon" ForeColor="White" />
<Columns>
<asp:BoundField Visible="false" DataField="scheduleid" HeaderText="Schedule id" ReadOnly="True" SortExpression="scheduleid" />
<asp:BoundField DataField="CustName" HeaderText="Custmer Name" SortExpression="CustName" />
<asp:BoundField DataField="meetinglocation" HeaderText="Meeting Location" SortExpression="meetinglocation" />
<asp:BoundField DataField="Begindate" HeaderText="Begin Date" dataformatstring="{0:MM-dd-yyyy}" SortExpression="Begindate" />
<asp:CommandField ShowSelectButton="True"  SelectText="&nbsp;View Details&nbsp;"/>
</Columns>
</asp:GridView>

Open in new window

Avatar of Rahul Agarwal
Rahul Agarwal
Flag of India image

Try this Code:


Code Behind:

protected void GridView1_RowDataBound(object sender, System.Web.UI.WebControls.GridViewRowEventArgs e)
{
      
      try {
if (e.Row.RowType == DataControlRowType.DataRow) {
      e.Row.Controls(3).Visible = false;
      LinkButton lnkBtn = (LinkButton)e.Row.Cells(5).Controls(0);
      lnkBtn.Attributes.Add("onclick", "return confirm('Are you sure you want to delete?');");
}
} catch (Exception ee) {
            lblmsg.Text = ee.Message.ToString();
      }
ASKER CERTIFIED SOLUTION
Avatar of karthitron
karthitron
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi, you have to use javascript alert box for it.