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

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

Datagrid with varying columns

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

I am upgrading a classic asp page, the page uses response.write to make a table, as soon as a null value comes up for a month the columns of the grid then stop.  The sql is below

SELECT sName, Strategy, 
Sum(case when Month([Date])=1 then Rtn else null end) as Jan, 
Sum(case when Month([Date])=2 then Rtn else null end) as Feb, 
Sum(case when Month([Date])=3 then Rtn else null end) as Mar, 
Sum(case when Month([Date])=4 then Rtn else null end) as Apr, 
Sum(case when Month([Date])=5 then Rtn else null end) as May, 
Sum(case when Month([Date])=6 then Rtn else null end) as Jun, 
Sum(case when Month([Date])=7 then Rtn else null end) as Jul, 
Sum(case when Month([Date])=8 then Rtn else null end) as Aug, 
Sum(case when Month([Date])=9 then Rtn else null end) as Sep, 
Sum(case when Month([Date])=10 then Rtn else null end) as Oct, 
Sum(case when Month([Date])=11 then Rtn else null end) as Nov, 
Sum(case when Month([Date])=12 then Rtn else null end) as Dec  
FROM Chess

If this is run in oct i only have data from jan -0ct , how do i not display nov and dec so that its dynamic?

View Complete Post

More Related Resource Links

How to bind datagrid columns to external (main) datacontext?



I have a datagrid and his columns binds well to its collection data. But when I add a new data column (ie. DataGridTextColumn or DataGridComboBoxColumn) and Bind to the main Data Context of window the data are missing (dont show)

In this sample, The last two columns of DataGrid dont bind to the main data.

<Window x:Class="MainWindow"





Sort WPF Datagrid using multiple columns



Is it possible to sort a WPF datagrid using more than one column ?



How add and bind DataGrid columns programmatically ??


Hi all,


How are you ??


please i need to know how to add and bind DataGrid columns programmatically ( NOT IN XAML),

i was using  this code in windowsForms i need equivalent for it in WPF please :

            DataGridViewColumn column = new DataGridViewTextBoxColumn();
            column.DataPropertyName = "DataPropertyName";
            column.Name = "columnName";
            column.DisplayIndex = 1;
            column.Width = 150;
            column.ReadOnly = true;
            column.Visible = true;


help me please , Thanks a lot .....






how to hide a column in a datagrid but autogenerated columns = "True"?



  Anybody help me please!!! I've 3 datasets named ds1, ds2, ds3. Then i merged that 3 datasets into 1 datatable named dt1. Now, my question is, i want to hide some datacolumns its present in an ds2. How????? Below i attached my code,



connectionString = "provider=MSDAORA;data source=proact;user id=mah;password=mah";


OleDbConnection myOleDbConnection = new OleDbConnection(connectionString);


Webform Grid Control With Varying Columns


I will do my best to explain what I am trying to accomplish.  I am trying to create a recipe system that will pull material amounts from an already built inventory database upon request for testing purposes of the different recipe runs.  What is throwing me for a loop is that each time a user will request a recipe comparison they will have a different number of recipe trial runs for comparison purposes.  In order to do this I'm guessing you will need to generate a gridview-like control with a dynamic number of columns which would be specified on a web form page prior to arriving at the recipe formulation page which will contain the control for the recipe formulation.  As a result the user will have different columns and rows on this formulation page, with the rows being a static number of 30 (30 being maximum amount of ingredients to include in each recipe).  The columns will contain the recipes to be compared, i.e. ProductRun1, ProductRun2, ProductRun3, where the number of ProductRunX will be determined by user input.  So the user when they come to this aspx page will be presented with a blank editable grid of X columns by 30 rows deep.  The left-most column will contain the ingredient names in a drop down box for users to select to input into their recipe and the rest of the columns will be editable fields where the user can type in t

I declared a datagrid in xaml, now I want to add main columns in this datagrid at runtime through vi


I have declared datagrid in xaml like this ;

<DataGrid AutoGenerateColumns="False" ........


and want to access this datagrid in viewmodel to add columns with headers to this datagrid at runtime. Actually i want to declare any number of columns in grid which i read from database table at execution time. If anybody could help me in this regard....

MS SQL Server: Search All Tables, Columns & Rows For Data or Keyword Query

If you need to search your entire database for specific data, this query will come in handy.

So when a client needs a custom report or some sort of custom development using Great Plains, most of the time I will have to track down the data in the system by running this query and find the table(s) it is in.

How to format and update GridView and DataGrid rows using JQuery

The behavior described in this question is as expected. When you set text of a cell in grid, it directly affects HTML that is going to be rendered. When you set text value of a cell, it means that you are setting innerText of the cell. The column that GridView creates for command fields (Edit, Delete and Select) are a (anchor) or button elements. So you can see what will happen if you set text value in that cell. It will wipe out those link or button controls and replace them with simple text string.

Use Jquery with repeater, gridview, datagrid

Before we talk about jquery inside any itemtemplate (repeater, gridview, datagrid), we need to understand the basic use of jquery functions

Adding Multiple Columns and Rows in GridView without using a Database

This article describes on how to add multiple columns and rows in GridView without using a database. Basically the GridView will be populated with data based on the values entered in each TextBoxes on Button Click and retain the GridView data on post back.

ListBox tricky to set in a DataGrid/GridView

Listboxes are very tricky to set selected items in grid - there is no real nice way to do it. It would have been great if Microsoft included a property that accepts an array or comma separated values - or anything! But they only allow each item in the list to be selected individually. The way to do this in a grid is a bit messy, but it is fairly simple to implement. When a row is created (as per the event), select the items of the listbox as per the datagrid source data:

add columns with textboxes in gridview using C#

'm working on a shopping cart in a website and I have my items(which have been added to the cart) in an arraylist. And using these values I've read the rest of the values from the db and and have populated on the gridview successfully.

How to highlight datagrid or GridView row on mouse over?

This article will show how you can Ajax with GridView to display popup messages when mouse moves over certain column. In the demo project I have added first column as an image column with a help icon in it. This kind of implements a feature that if you want more information about the row you can move mouse over this icon, a asynchronous request is sent to server for data about that row and when call returns the returned message is show as a popup message.

Custom Editing Behavior for DataGridView TextBox Columns

For various reasons I'm using a DataGridView instead of a ListView, and while configuring the DataGridView to look like a ListView wasn't much of a problem, there's one thing that got on my nerves, which is the behavior of textbox cells in edit mode: It is much too easy to leave the edit mode accidentally, simply by pressing the cursor keys at the wrong time. For example when the text caret is positioned behind the last character of the textbox cell content, and you press the right arrow key

Multiple Column Dropdownlist for the ASP.NET DataGrid

Based on my previous control "Multiple Column DropDownList for ASP.NET", I received many emails asking for the same control to be used in the DataGrid for web applications. Here we go.. This control can be used as the regular MS DropDownList in the DataGrid and also as a regular dropdownlist. It has all the properties, like DataTextField, DataValueField, DataSource, SelectedIndex etc. The download file contains the samples both in VB.NET and C#. In this sample, I have used the Northwind database of SQL Server.

Using the WPF Toolkit DataGrid

WPF comes with a large number of built in controls, but from the beginning it has lacked something that many application developers find extremely important - a DataGrid. You can use the ListView to create something approximating a DataGrid

Sorting GridView Columns Manually

We all know that GridView columns can be sorted automatically when SQLDataSource is being used. But what if you are not using SqlDataSource to populate the GridView. Sorting the GridView manually is pretty straight forward task take a look at the code below
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