Infragistics UltraGrid

I need to populate the Infragistics UltraGrid. I am using the datasset. The stored procedure returns 2 columns month, year.For month it returns the 1,2..........or 12.I can't change the storedprocedure
I am thinking of adding a column to the dataset which displays month and year. It shouldbe like this.January,2008. It has to combine the month and year columns and month number substituted with month name.
Pls let me know the possible ways of doing this.
Thank You
KavyaVAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ZeonFlashCommented:
Instead of adding a column to the dataset, you can just add an unbound column to hold the combined month/year, and populate it in the InitializeRow event.  I used a VB.NET->C# translator to get the code below, so let me know if it doesn't work:
    private void UltraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e) {
        UltraGrid1.DisplayLayout.Bands(0).Columns.Add("CombinedDate");
        UltraGrid1.DisplayLayout.Bands(0).Columns["CombinedDate"].DataType = typeof(DateTime);
        UltraGrid1.DisplayLayout.Bands(0).Columns["CombinedDate"].Format = "MMMM yyyy";
        UltraGrid1.DisplayLayout.Bands(0).Columns["Month"].Hidden = true;
        UltraGrid1.DisplayLayout.Bands(0).Columns["Year"].Hidden = true;
    }
    
    private void UltraGrid1_InitializeRow(object sender, Infragistics.Win.UltraWinGrid.InitializeRowEventArgs e) {
        e.Row.Cells["CombinedDate"].Value = DateTime.Parse((e.Row.Cells["Month"].Value + ("/01/" + e.Row.Cells["Year"].Value)));
    }

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
KavyaVAuthor Commented:
ZeonFlash,
I tried what you suggested.But it's not working. the ultragrid has 3 more columns other than the combineddate.The data for those 3 columns are displayed.I added 3 columns to the ultragrid by clicking the start designing the gridview. I used manually define a schema  and band&column settings. I added 3 columns ID,Volumechanged,VolumeTotal like this and hide the month and year columns.
Then in the code I did like this:
private void  UltraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e)
        {
            UltraGrid1.DisplayLayout.Bands[0].Columns.Add("CombinedDate");
            UltraGrid1.DisplayLayout.Bands[0].Columns["CombinedDate"].DataType = typeof(DateTime);
            UltraGrid1.DisplayLayout.Bands[0].Columns["CombinedDate"].Format = "MMMM yyyy";
          }
        private void  UltraGrid1_InitializeRow(object sender, Infragistics.Win.UltraWinGrid.InitializeRowEventArgs e)
        {
            e.Row.Cells["CombinedDate"].Value = DateTime.Parse((e.Row.Cells["Month"].Value + ("/01/" + e.Row.Cells["Year"].Value)));
        }
I retrieved the dataset and assigned to grid.
UltraGrid1.Datasource= ds;
UltraGrid1.Datamember = "volume";
The 3 columns(id,volume changed,volume total) are populated with the data. The CombinedDate column is not added to the UltraGrid.
2)In the 2nd case I added one unbound column CombinedDate while manually designing the gridview
and use the UltraGrid1_InitializeRow method.In this case the row is added to the grid and is not populated with the data.

Is there any mistakes in the way I did. Pls let me know how to populate the CombinedDate column.

Thank You.




0
ZeonFlashCommented:
Did you add the InitializeRow event handler to the InitializeComponent routine?
private void InitializeComponent()
{
	Infragistics.Win.UltraWinGrid.UltraGridBand ultraGridBand1 = new Infragistics.Win.UltraWinGrid.UltraGridBand("Band 0", -1);
.
.
.
	this.ultraGrid1.TabIndex = 0;
	this.ultraGrid1.Text = "ultraGrid1";
	this.ultraGrid1.InitializeLayout += new Infragistics.Win.UltraWinGrid.InitializeLayoutEventHandler(this.ultraGrid1_InitializeLayout);
	this.ultraGrid1.InitializeRow += new Infragistics.Win.UltraWinGrid.InitializeRowEventHandler(ultraGrid1_InitializeRow);  //Add this line
.
.
.

Open in new window

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.