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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
kumar manish6 reputationPosted Apr 6, 2015, 3:11 AM EDT
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.
}
}
Shakti Singh DulawatRank #668 · 3.6K reputationPosted Apr 6, 2015, 3:12 AM EDT
Now you can specify your server side event name here, I assume you are using asp,net Grid view
Khargesh RajputRank #616 · 3.9K reputationPosted Apr 6, 2015, 3:13 AM EDT
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
Dinesh Singh85 reputationPosted Apr 6, 2015, 3:47 AM EDT
Khargesh RajputRank #616 · 3.9K reputationPosted Apr 6, 2015, 3:51 AM EDT
Deepak SainiRank #2,411 · 586 reputationPosted Apr 6, 2015, 5:01 AM EDT
your put a button on the grid and make manual click event on this button.this is work fine on the rowdatebound.