473,406 Members | 2,956 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

rowcommand is not firing in grid view

hi guys rowcommand event id not firing my code is

Expand|Select|Wrap|Line Numbers
  1.         <asp:GridView ID="gridView"  runat="server" Style="position: relative" PageSize="5"  OnRowCommand="gridView_OnRowCommand"  AllowPaging="True" >
  2.  
  3.         <PagerTemplate>
  4.  
  5.     <% if (gridView.PageIndex > 0)
  6.     { %>
  7.     <asp:ImageButton ID="imgBtnPrevious" runat="server"
  8.     Style="vertical-align: middle;" img src="pre.jpg" 
  9.     CommandArgument='<%# Eval("pre")%>' CommandName="Page" />
  10.     <% } %>
  11.     <%=(gridView.PageIndex * 5) + 1%> - <%=(gridView.PageIndex * 5) + gridView.Rows.Count%>
  12.     <% if (gridView.PageIndex != (gridView.PageCount - 1))
  13.     { %>
  14.     <asp:ImageButton ID="imgBtnNext" runat="server"
  15.     Style="vertical-align: middle;" ImageUrl="next.jpg" 
  16.       CommandArgument='<%# Eval("Next")%>' CommandName="Page" />
  17.     <% } %>
  18.     </PagerTemplate>
  19.         </asp:GridView>



in code behind

Expand|Select|Wrap|Line Numbers
  1. protected void gridView_OnRowCommand(object sender, CommandEventArgs e)
  2.     {    
  3.         try   
  4.      {
  5.         //Get the current page selected    
  6.  
  7.            int intCurIndex = gridView.PageIndex;        
  8.         //Switch-Case to handle to Previous and Next paging       
  9.         switch (e.CommandArgument.ToString().ToLower())     
  10.          {            
  11.  
  12.             case "prev":  
  13.                 if (intCurIndex > 0)  
  14.                     gridView.PageIndex = intCurIndex - 1; 
  15.                 break;            
  16.             case "next":                
  17.                 if (intCurIndex < gridView.PageCount - 1) 
  18.                     gridView.PageIndex = intCurIndex + 1;   
  19.                 break;        }      
  20.         // popultate the gridview control  
  21.                 DataSet ds = new DataSet();
  22.                 SqlDataAdapter adapPaging = new SqlDataAdapter("select * from customer", "Data Source=OPWFMS-7KYGZ7SB;Initial Catalog=Mayank;User ID=sa;Password=sa");
  23.                 adapPaging.Fill(ds);
  24.  
  25.  
  26.                 gridView.DataSource = ds;
  27.                 gridView.DataBind(); 
  28.  
  29.     }  
plz tel me how to resolve this
Jul 13 '09 #1
1 5752
Frinavale
9,735 Expert Mod 8TB
Hi Pupilstuff,

Based on your other thread I'm assuming that you're dynamic controls are not firing the RowCommand event.

Say you implement a class that implements the ITemplate interface...and in that class you dynamically create a control that causes the page to postback (like buttons, orlink buttons) in the InstantiateIn method.

When that dynamic control posts back to the server, the event (the click event for example) will be handled by the class that implements the ITemplate interface....because it belongs to that class.

If you want to be able to handle the click event in your Page code (which is a class) then you have to raise an event in in the ITemplate class to indicate so.

You cannot use the RowCommand in this case.
Jul 13 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: SteveC | last post by:
In my ASP.NEt codebehind, I declare a public var for a DataGrid. Then in the TextChanged event handler for a TextBox, I create a <div> tag, stuff it inside the form, then instance a DataGrid and...
6
by: Kevin Attard | last post by:
I am using a GridView inside a UserControl which has a template column for deleting the rows. Before databinding the gridview i am attaching the RowCommand and RowDataBound event. I am using the...
13
by: AG | last post by:
I have a gridview that I bind to a List(of Type) at runtime. Not using a datasource control. The gridview has a template column with an imagebutton whose commandname is set to 'Delete'. The...
1
by: Muhammad Saad Abbasi | last post by:
Hello, I have a problem that I may not be able to get the row index in template column in grid view. Can anyone help me for this problem. *** Sent via Developersdex...
7
by: =?Utf-8?B?cGF0cmlja2RyZA==?= | last post by:
Hi all! I have a gridview inside a datagrid (nested) for which (gridview) the rowcommand is not raised in order to delete a row from the grid! I also tried OnRowCommand="method", didn't work...
2
by: John007 | last post by:
I am using a GridView in ASP.Net 2.0 to Insert, Edit, Update and Delete. I am using ItemTemplate and EditItemTemplate and the buttons are LinkButtons. I am inserting a new row from the footer. The...
1
by: HockeyFan | last post by:
protected void gvAuthorizedSigners_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "EmptyInsert") { odsAuthorizedSigners.Insert(); return; } if (e.CommandName...
0
by: jrnail23 | last post by:
I have a user control which contains an UpdatePanel, which contains a MultiView inside, with a GridView in one of the views. In my GridView, I have a ButtonField which is supposed to trigger a...
0
by: =?Utf-8?B?YmVuamk=?= | last post by:
Hi, I've got a gridview that I bind programmatically to a view of a typed dataset. One column has a command button, and in the RowCreated event, I test to see if it's a DataRow, and if it is, I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.