.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Grouping gridview with gridhelper returns wrong row index

Posted By:      Posted Date: October 15, 2010    Points: 0   Category :ASP.Net


I'm using a GridView and GridViewHelper Class (http://www.agrinei.com/gridviewhelper/gridviewhelper_en.htm) for grouping the grid by desired field. On the grid I also include an "edit" RowCommand.



ID ... Name ... Company ... Year ... RowCommand



1 ... Alex ... Comp1 ... 1999 ... Edit

2 ... Jane ... Comp2 ... 1999 ... Edit


3 ... Mike ... Comp1 ... 1999 ... Edit

Now when I click edit in the second row of the grid (ID=1, the Group itself is shown in the first row) I have the following code on RowCommand:

// Convert the row index stored in the CommandArgument
                    // property to an Integer.
                    int index = Convert.ToInt32(e.CommandArgument);

                    // Retrieve the row that contains the button clicked 
                    // by the user from the Rows collection.
                    GridViewRow row = GridView1.Rows[index];

and the index returned is 0 instead of 1. Why? And how can I fix this, because the edit command returns error or points to the wrong records??<

View Complete Post

More Related Resource Links

Grouping Gridview with jquery

The requirement of the project is to show a table of data with the riskdetails(just for assumption) which have the corresponing values for every month and people used to compare the values for last months.

Building a grouping Grid with GridView and ASP.NET AJAX toolkit CollapsiblePanel

I've posted an update to this post to apply on demand loading of Details data using ASP.NET AJAX PageMethods. I'm demonstrating the usage if CollapsiblePanelExtender client events on the new post. Check it out.

I admit, Matt Berseth is really inspiring me! Few days ago I pass through 2 of his great posts:

.Surrounding your Data Table and Dialog Controls with ComponentArt Styled Panels
.Building a Grouping Grid with the ASP.NET 3.5 LinqDataSource and ListView Controls
The first one is pure design tips one which I used for making good presentation of my demo here. The 2nd post is actually the idea.

Grouping Gridview with jquery in asp.net

The requirement of the project is to show a table of data with the riskdetails(just for assumption) which have the corresponing values for every month and people used to compare the values for last months.

grouping summary data gridview


how can I gruping summary data in gridview like that; Thanks for helping


Car                   Rate 1               Rate 2            Rate 3  

 BMV                 5                          7                       9

                         4                          6                      7


SharePoint Search returns wrong date

Hi i am running a Sharepoint 2010 enterprise search indexing a file folder structure with emails(.eml) and attachments(.doc(x), pdf, xls(x), ...). The search results shows a date like first full index time or something like that, but not the date of file creation or any other attributes of the file. My questions: - what may be the reason of the wrong date? - is there a possibility use another attribute for displaying that is more relevante? Please help Kind regards Werner Durrer    

Grouping Issue in Gridview

Consider Table in Database Table Name: Work_Order   Work_Id Height Width Thickness Material Shape 11-1 20.3 32.5 50.2 Steel U 11-2 20.3 32.5 50.2 Steel O 11-3 20.3 32.5 50.2 Steel U 11-4 22.3 32.5 50.2 Iron V 11-5 22.3 32.5 50.2 Iron V 11-6 30.3 52.5 63.2 Steel O 11-7 30.3 52.5 63.2 Steel U   Please Provide me the Sqlcommands and method to display the above in an asp.net  Grid View as shown below.   Material Height Width Thickness Shape Steel         11-1 20.3 32.5 50.2 U 11-2 20.3 32.5 50.2 O 11-3 20.3 32.5 50.2 U Steel         11-6 30.3 52.5 63.2 U 11-7 30.3 52.5 63.2 U Iron         11-4 22.3 32.5 50.2 V 11-5 22.3 32.5 50.2 V  Basically I would like group above by Material and check if Height,Weight, Thickness (shape not beconsidered) are same.Is it possible to display the above?

Gridview Grouping issue

Consider a table in DatabaseTable name: Work_OrderWork_Id     Height        Width        Thickness    Material     Shape11-1             20.3cm       32.5cm       50.2cm        Steel            U 11-2             20.3cm       32.5cm       50.2cm        Steel            V11-3             42.3cm       72.5cm       80.5cm        Steel            O11-4             42.3cm       72.5cm       80.5cm        Steel            U11-5             30.3cm       62.5cm       25.2cm        Iron              V11-6             30.3cm       62.5cm       25.2cm        Iron              U Please Provide me the Sql commands a

SQL 2008 External access returns wrong address for Report Manager

Hello, I have problems with the external access for report server. My report server is running in a local server on port 80, which can be accessed through http://servername/reports I have set up external access to the report server through http://servername.domain.com:8081/reports , so I set up a redirection from public port 8081 to port 80 on the local server. When I write the address http://servername.domain.com:8081/reports in a browser, I get asked for user authentication(Windows domain user), which is accepted, but after that I get an error because the URL automatically changes to http://servername.domain.com/Reports/Pages/Folder.aspx (without the port 8081) If I write http://servername.domain.com:8081/Reports/Pages/Folder.aspx , it works. I can see the report manager home page and browse through my reports. But there are some links in the page that are built improperly, since they still point to the wrong URL (without port 8081). These are e.g. the Help link, the Report Builder link, the Details view link.  So I think there is something wrong with the response the report server sends, when I write ".../Reports" and returns ".../Reports/Pages/Folders.aspx" I haven't found any configuration file or property where this response is specified, neither where the report

gridview column index

how can i change column index of girdview ,i have to show button at right hand side

change index of dropdown in gridview


 i have got grid view with 4 coloums which contains 2 dropdown list. n i have 2 drop down list out side the gridview .

i want to change the index of the 1st coloum  dropdown list inside the gridview when changing the drop down list  index outside using javascript

similarly the when the 2nd dropdown list(out side ) index change the 2nd coloumn dropdown list in gridview should change..

 In short the outside placed dropdown list should act as master dropdown list.

GridView Rowupdating Returns old Values


Haii all, my gridview row updating events return old values.. edititem templatefield gets its old value on row updation.

My code is as follows :-

      protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)

        TextBox tb1 = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txt3");
        TextBox tb2 = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txt4");
        TextBox tb3 = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txt5");
        TextBox tb4 = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txt6");
        TextBox tb5 = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txt7");

        string s1 = tb1.Text;
        string s2 = tb2.Text;
        string s3 = tb3.Text;
        string s4 = tb4.Text;
        string s5 = tb5.Text;

        string qry="Update SparePartsStatus set Equipment='"+s1+"',Location='"+s2+"',TotalQuantity='"+s3+"',DateofDelivery='"+s4+"',Balance='"+s5+"' where (SpareName='"+Session["partno"]+"')";
SqlCommand com=new SqlCommand(qry ,con);
        int d = com.ExecuteNonQuery();


row index of gridview on popup extnerder image


hi to all

i have a gridview which contain a textbox an imagebutton which will popup a popup window

if i m using model popup extender i m able to fetch the row index of gridview  through command arguement  in rowcommand event

but as if i m using popup extender i m not able to fetch the row index of gridview its not identifying the command arguement

is there any other way to do so

example of Model Popup extender



BDC field returns wrong value in the Value Picker



I have a BDC entity in an application with multiple functioning entities but one of the entities is not behaving.

it returns a list of varchar(100) values and it works in application configuration tool when tested.

When I use the Picker, I see the values in the list but when I select a value and the picker closes, the value left in the control on the screen is not the value I selected "Technical" but a value I do not understand


no data in the table even resembles this value.  I have a hunch this is the word "Technical" in some encoded form.


Here is a snippet from the BDC definition

The GetAll method is the one that is causing the pain. 

any help would be greatly apreciated.


 I had to delete the top two methods to get this to post on this site.(they were the auto created methods from the BDC tool

The error w

Why it returns null (GridView)TemplateContainer.FindControl("gridView")?



I created a new custom field definition.

But on CreateChildControls event it always return null in my components. Where is error? What should I do to make work it properly?


protected override void CreateChildControls()


if (this.Field == null) return;


if (this.Field != null && this.ControlMode!= SPControlMode.Display)

this.MyPrefix = (Label)TemplateContainer.FindControl("MyPrefix");
if (this.MyPrefix == null)
    throw new ArgumentException("Corrupted PermissionControl template - missing ProofHQUserPermissionPrefix.");
this.gridView = (GridView)TemplateContainer.FindControl("gridView");
if (this.gridView == null)
    throw new ArgumentException("Corrupted PermissionControl template - missing GridView.");



All components are defined in template PermissionControl.

Getting index number of GridView Control


 I am trying access the row index on this GridView, but the e.CommandArgument gives me a value of an empty string "" , so the the error handler kicks in. What do you think I am missing.


protected void GridView2_RowCommand(object sender, GridViewCommandEventArgs e)
        if( e.CommandName == "Delete" )
            int index = 0;
                index = Convert.ToInt32(e.CommandArgument);
            catch (Exception p)
                Response.Redirect("RbErrorPage.aspx?pagefrom=GridView2_RowCommandgMethodLine4122" + p.Message);

gridview grouping



i am using this component http://www.agrinei.com/gridviewhelper/gridviewhelper_en.htm from agrinei, it works just great if you bound it to some table of your DB. In my case i have created a datatable and dataset wich i create dinamically and then add rowws to them and finally i set grid's datasource with this datatable, with this implementation the componnete does not work any workaround this?


RowCommand returns null value for controls which are not binded to Gridview source


I am tryting to reach controls in the gridview rows by RowCommand event. I can take values of controls which are binded to gridview source successfully . But for all other controls which is not binded to gridview returns NULL value. All controls run at server. Why is that?

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend