here is the sample code
html code
<asp:TemplateField HeaderText="Header 3">
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text="Click Me"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
and CodeBehind is
protected void Gridview1_RowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
Label l = (Label)e.Row.FindControl("Label1");
if (l != null)
{
string script = "window.open('Default.aspx');";
l.Attributes.Add("onclick", script);
}
}
}
run the Application and click "Click Me" it will open new window , indirectly we are adding
OnClick Event in That Row.
No comments:
Post a Comment