How do i use button_Click event
How do i use button_Click event that button is inside the gridview control
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Deepak SainiPosted Apr 6, 2015, 9:01 AM
your put a button on the grid and make manual click event on this button.this is work fine on the rowdatebound.
Khargesh RajputPosted Apr 6, 2015, 7:51 AM
Dinesh SinghPosted Apr 6, 2015, 7:47 AM
Khargesh RajputPosted Apr 6, 2015, 7:13 AM
select smart tag in gridview like arrow >
then edit templates
then inside item template select column which has your button inside column
you can now select and double click on button like
and
another way is write Onclick="btn_click" inside button (create event handler)
and
protected void btn_Click(object sender, EventArgs e)
{
}
or
just by select button code in aspx and press f4 you will get properties and events on right side
Shakti Singh DulawatPosted Apr 6, 2015, 7:12 AM
Now you can specify your server side event name here, I assume you are using asp,net Grid view
kumar manishPosted Apr 6, 2015, 7:11 AM
Aspx code :
CS Code :
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{ if (e.CommandName == "AddToCart") {
// Retrieve the row index stored in the // CommandArgument property.
int index = Convert.ToInt32(e.CommandArgument);
// Retrieve the row that contains the button // from the Rows collection.
GridViewRow row = GridView1.Rows[index];
// Add code here to add the item to the shopping cart.
}
}