ultrawinGrid -assigning the datasource

In the Initialize Layout  event of the ultrawinGrid I have for loop. I dynamically added the columns to wingrid. In each iteration I make a call to the database and the dataset will returned. I need to assign the one column of the dataset the ultrawinGrid column.
The code is as follows:

for(int i=0;i<noofstudents;i++)
{
   string columnIndex = "student" +i;
    ultraGrid1.DisplayLayOut.Bands[0].Columns.Add(columnIndex);
   serviceClass.returndataSet(mno,yr,id,out dsStudent);
 ultraGrid1.DisplayLayout.Bands[0].Columns[columnIndex] =  dsStudent.Tables"student"].Columns"student_marks"];
}
It's is showing the error. 1.cannot implicitly convert type 'System.Data.DataColumn'  to 'Infragistics.Win.UltraWinGrid.UltraGrid Column'.
2.Property or Indexer ' 'Infragistics.Win.UltraWinGrid.ColumnCollection.this[string]' can not be assigned -- it is read only.

Pls help me how to assign the dataset column to wingrid column.

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.

AgariciCommented:
you should probably have a datasource property on the grid. try to assign the dataset or datatable to it. then you should bind the grid columns to dataset table columns.

(this is only generic idea because i am not familiar with the infragistics control you are using. but the flow should be the same. only details like api names should differ)

hth,
A.
0
KavyaVAuthor Commented:
Grid has the datasource property. But I need to assign the dataset column to the dynamically generated
ultragrid column.ultrawingrid column has no data source property.
0
AgariciCommented:
it should have some dataMember displayMember valueMember or something similar where you can put the datatable column name you want it bound to.

hth,
A.
0
AgariciCommented:
another idea: create the binding in the designer and then look into the designer generated code.
0
Guy2Commented:
Hi KavyaV,

The answer depends on how the dsStudent dataSet is modified:
- if a dataset is recreated (ie dsStudent = new DataSet())  on each returndataSet method call, you'll need to rebind the UltraGrid control to the datasource, as the dataSet object is not the same. To do this, simply reassign the UltraGrid's dataSource property with the new dataSet (dsStudent);

- if columns are added to the existing dataset table (ie dsStudent.Table(0).Columns.add(...)), the datasource reference do not change and new columns will automatically be reflected in you ultraGrid control, but you can force the control update by calling the UltraGrid.DataBind() method.

One last thing, I do not think it is a good practice to change the UltraGrid datasource during the InitializeLayout event, as, during this event, the control is creating its content based on its datasource, and if it change, the same event may be re-fired (infinite recursive call)... Try to update your datasource elsewhere...
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
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.