Click here to Skip to main content
16,018,353 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi all

i have a grid view and i made ButtonField on it like below

ASP.NET
<asp:ButtonField ButtonType="Button" CommandName="AddToBasket" Text="Add to Basket" />


while i clicked on it , no event occurs , however i made a function with the same name

C#
public bool AddToBasket(string cart_id, string item_id, string price, string quantity)


any help, please

thanks
Posted

C#
there is no event handler written in asp:ButtonField tag, write eventhandler for the commandclick and assign ur c sharp method  in that event handler
 
Share this answer
 
Add a rowcommand event in your gridview like this:

ASP.NET
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
onrowcommand="GridView1_RowCommand" CellPadding="4" ForeColor="#333333"GridLines="None">


Handle it in codebehind as;
C#
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
//you functionality
}
 
Share this answer
 
v2

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