C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Code Snippets » ASP.NET GridView »

using Gridview RowCommand Event


Posted Date: 28 Nov 2008    Resource Type: Code Snippets    Category: ASP.NET GridView
Author: narenderraobalguriMember Level: Silver    
Rating: 1 out of 5Points: 5



hi all,
for using a Rowcommand event in gridview for buttons for u palce two buttons in gridview colums.
code:
AutoGenerateColumns="False" OnRowCommand="gvstaff_RowCommand" Width="100%" DataKeyNames="bigint_StaffId">











<%# DataBinder.Eval(Container.DataItem,"NoOfAscents") %>




Select







in the above code i placed two linkbuttons with command names show and Select1
Now we will see the Server side code for Rowcommand event
COde:
if (e.CommandName == "Show")
{
GridViewRow row = (GridViewRow)((Control)e.CommandSource).NamingContainer;
int DemoId = Convert.ToInt32(gvdemo.DataKeys[row.RowIndex].Value);
//You will get id here.....You code goes Here....
}
else if (e.CommandName == "Select1")
{
GridViewRow row = (GridViewRow)((Control)e.CommandSource).NamingContainer;
int DemoId = Convert.ToInt32(gvdemo.DataKeys[row.RowIndex].Value);
//You will get id here.....You code goes Here....
}
}




Responses

Author: Nadine    29 Apr 2009Member Level: Bronze   Points : 1
I find that the RowCommand Event fires twice? Why is that so? Ant help or suggestions.


Author: narenderraobalguri    01 May 2009Member Level: Silver   Points : 0
can u tell in briefly,i mean when it will be happening?


Author: Nadine    04 May 2009Member Level: Bronze   Points : 1
Hi, I have found out that if you have a ButtonField with the ButtonType set to image within a GridView the RowCommand Event fires twice or sometimes more. The problem lies with Internet Explorer, to solve the problem I have used Template Fields instead.


Author: greeny_1984    13 May 2009Member Level: Diamond   Points : 1
Hi,

It would have been more effective

with good description

regards,

greeny


Author: cool    04 Jun 2009Member Level: Bronze   Points : 0
Good one .


Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
Rowcoomand event  .  Row Command of gridview  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Combining Two Grid View Headers Using ASP.NET
Previous Resource: Adding Javascript Alert for Delete button in Gridview
Return to Discussion Resource Index
Post New Resource
Category: ASP.NET GridView


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use