Click here to Skip to main content
16,015,481 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have gridview in a page with button.

i want to execute a query when user click button and then that row should be deleted.

I was trying a demo but it is not working.



XML
<asp:GridView ID="GridView1" runat="server"
onselectedindexchanged="GridView1_SelectedIndexChanged">
<Columns>
<asp:TemplateField HeaderText="Delete" HeaderStyle-CssClass="title_bg" ItemStyle-HorizontalAlign="Center">
<asp:LinkButton ID="lkDelte" runat="server" OnClientClick="return confirm('Are you sure you want to delete?')"
CommandArgument="<%# ((GridViewRow) Container).RowIndex %>"
CommandName="y" ><img src="Images/A5.gif" alt="Delete" border="0" /></asp:LinkButton>
</ItemTemplate>
<pre lang="xml"><asp:ButtonField CommandName="Updateit" Text="Button" />
</Columns></asp:GridView>





code:



void GridView1_RowCommand(Object sender, GridViewCommandEventArgs e)
{


if (e.CommandName == "y")
{
Response.Write("hello");
}


}




Friends Please Help Me....!!!
Posted
Comments
[no name] 1-May-12 17:11pm    
"it's not working" does not do very much to help us help you. What is not working?
Pr!y@ 1-May-12 17:13pm    
page is executing but hello is not printing

1 solution

ohhhh ,,


I was missing

OnRowCommand="GridView1_RowCommand" in aspx page.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900