.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 Issue in Gridview

Posted By:      Posted Date: September 03, 2010    Points: 0   Category :ASP.Net
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?

View Complete Post

More Related Resource Links

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

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


Gridview Performance Issue

Hi All, I have one ASP.NET Application (VS.NET 2005). In that i have one scenario where i have to display 500 records per page (Not less than that bcoz this is client requirement to display 500 records per page) in the Gridview. This functionality is working fine but the application is becoming very slow. Can anybody tell me the solution for increasing performance in this case ???? VERY URGENT...PLZ REPLY SOON Thanks, Biswajit

Gridview placing issue

hi all,       Actually I am binding 5 gridviews on a form. I done that if gridvew having nay data then it should visible others wise invisible.       there  all 5 gridvew may have data or not and may be 2 or 3 of them having data, depens on the condition.        If gridview1, gridview2, gridview3 dont bind any data then they dont appear on the form only gridview4, gridview5 are binding data and they are appearing on the form. but ther are very down in the form, what I want is ; which ever gridview bind the data it showld not show space bitween form head and the gridview, means if upper all 4 grid are not binding and 5th is binding the it should not appear in the bottom of the form instead it should visible on the top. it's like there are no grid except this grod on the form, i dont need to scroll the form to view the grid.thanksGaurav

dropdownlist controls in gridview issue

 the below code creates drop down each time i add a category to the database table. however, i don't wish to have drop down created each time - how can i have all my data in one drop down? thanks...  <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:CascadingDropDownTestConnectionString %>"  SelectCommand="SELECT [CategoryID], [CategoryName] FROM [Category]">  </asp:SqlDataSource>    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="CategoryID"  DataSourceID="SqlDataSource1">  <Columns>  <asp:BoundField DataField="CategoryID" HeaderText="CategoryID" InsertVisible="False"  ReadOnly="True" SortExpression="CategoryID" />  <asp:TemplateField HeaderText="Categories">  <ItemTemplate>  <asp:DropDownList ID="ddlCategories" AutoPostBack="true" DataTextField="CategoryName"  DataValueField="CategoryID" DataSourceID="SqlDataSource1" runat="server" AppendDataBoundItems="true"  SelectedValue='<%# Bind("CategoryID") %>' />  &

Gridview Fixed Header Issue


   position:relative ;
   z-index: 10;
2.Assign Datagrid Header's cssClass to Freezing
<HeaderStyle ... CssClass= "Freezing" ...></HeaderStyle>


This is working fine in Internet Explorer but not working in firefox. can anybody please help me to say why its not working in firefox

CQWP QueryOverride grouping issue



I have extended content query web part and using dynamic caml for query. I specified grouping in toolpart but the same group headers will appear several times. I referred http://sptoolbox.codeplex.com/Thread/View.aspx?ThreadId=33346 and many other posts which said this issue can be solved using OrderBy in the dynamic caml for the same field as grouping.

I tried adding OrderBy in the caml but run into errors. Follwing code works fine if OrderBy is removed:

            public string CreateCAMLQuery(List<string> names)
                StringBuilder sb = new StringBuilder();
                for (int i = 0; i < names.Count; i++)
                    AppendEQ(sb, names[i]);

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?


One Gridview & Multiple CommandText Issue on Paging


Hi All,

I am using a gridview to display data from two separate functions. [VS 2010 on Framework 4]

This works fine without paging. On paging, clicking 'next page' invokes the older data(of function 1) instead of that in the new function (function 2) Cry


' Function 1

cmd.CommandText = "select * from table1,
Dim dTable As DataTable
Dim dataAdapter As SqlDataAdapter
            dTable = New DataTable
            dataAdapter = New SqlDataAdapter(cmd.CommandText, AquisitionString)

'Function 2

cmd.CommandText = "select * from table2,
Dim dTable As DataTable
Dim dataAdapter As SqlDataAdapter
            dTable = New DataTable
            dataAdapter = New SqlDataAdapter(cmd.CommandText, AquisitionString)

'Handling PageIndexChange

   Protected Sub grdAcquisition_PageIndexChanging(ByVal sender As Object, _
       ByVal e As System.Web.UI.WebControls.GridViewPageEventArgs) Handles grdAcquisition.PageIndexChanging

display message if gridview has no row issue


(1) i want to show message if no data row is found in the grid. but my code below does not achieve this. basically if gridview shows data then i want my panel (booking form) to be made visible otherwise hidden. the booking form panel is set to visible false. my else statement is not working...

        protected void btnCheckFlightAvailability_Click(object sender, EventArgs e)
            if (Page.IsPostBack)
                this.gvSingleFlightSearch.DataSourceID = "CheckSingleFlightDataSource";

                if (gvSingleFlightSearch.EmptyDataText != null)
                    pnlFlightAvailableMessage.Visible = true;
                    lblAvailableFlights.Text = "Flight Available";
                    gvSingleFlightSearch.Visible = true;


                        pnlFlightAvailableMessage.Visible = false;
                        lblAvailableFlights.Text = "No Flight Available";
                        gvSingleFlightSearch.Visible = false;

(2) one of the field in my grid view is price while a texbox in my booking form is passenger numbers. how can i use the value entered

Performance issue with GridView


Hi All,

             i am facing performance issue while using the datagrid in my project, i am writing my code here please correct me if i am writing something wrong.

i am using sql server 2000 in which i have a table containing around 600000 records and i can not put any indexing on this table as this is the staging table for me .

now To show these record on front end i am using gridview with Allowpaging = "True" now in the PageIndexChanged event i have to again hit the database and bind the grid which results very slows performance as just to change the page i have to read 600000 records again and again, i am giving some idea below what i am doing

Public Void BindgridView()


//do database connection

//fill the dataset through adapter

Gridview.datasource = dataset();



protected void GridView_PageIndexChanging(object sender, GridViewPageEventArgs e)
      GridView1.PageIndex = e.NewPageIndex;

Any idea how can i imrove the performance, Please help me out..



Issue with row and column Grouping

In my report I have two row groups one below the other that belong to the same parent group. I also have a column group. What happens is until I have only one row group and one column group the report works fine. When I add a second row group below the first one the values are displayed correct for this second row grouping but the values for the first row group which were earlier correct are not shown. The display for those values is blank. Can anyone help with why this is happening? 

GridView and FindControl issue..


Hi guys,

I dont seem to find any control using the FindControl method over gridviews "on edit". I have pasted my code below, please tell me if m doing something wrong or missing something..

ASPX page:

<asp:GridView ID="gvCountry" runat="server" AutoGenerateColumns="False" 
                <asp:TemplateField HeaderText="Edit">
                        <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="True" 
                            CommandName="Update" Text="Update"></asp:LinkButton>
                         <asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" 
                            CommandName="Cancel" Text="Cancel"></asp:LinkButton>
                        <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" 

Grouping gridview with gridhelper returns wrong row index



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??<

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