Hi Everyone,
I am having some REAL difficulty with getting a DropDownList to appear in an UltraWebGrid column. I have searched far and wide for the correct way to setup a DropDownList and for some reason I cannot get to dropdown list to appear even in an overly simple senario.
I have followed these approaches: http://forums.infragistics.com/forums/t/14767.aspx , http://news.infragistics.com/forums/t/9063.aspx, http://news.infragistics.com/forums/p/11438/43300.aspx#43300 , http://news.infragistics.com/forums/p/10880/41315.aspx#41315
Furthermore, I have run the example http://devcenter.infragistics.com/download/samples/kb/webgridcomplexrowtemplate.zip in which the grid still doesn't show a dropdown (or rowedittemplate).
I have set up a VERY simple example where I just try to create a drop down list in a page load and bind but still nothing shows, here is the logic:
protected void Page_Load(object sender, EventArgs e)
{
UltraGridColumn c = b.Columns[0];
c.Header.Caption = "code-behind";
List<Class1> cl1 = new List<Class1>(0);
c.ValueList.DataSource = cl1;
c.ValueList.DisplayMember = "Name";
c.ValueList.DataSourceID = "Id";
c.ValueList.DataBind();
Where class1 has two members, Id and Name. I get a column called "code-behind" but no dropdownlist.
Can someone please shed some light on what I am missing?
Thanks for any help,
Jason
I haven't tested your code, but I see one line that jumps out at me:
c.ValueList.DataMember = "Id";
Try removing this line and see if it works. This property is used in combination with the DataSource property to specify a given list within a set of lists (such as the name of a DataTable within a DataSet).
Is your WebGrid databound? If so, then I suggest moving this logic to the InitializeLayout event, so that you know it'll be called when the grid is databound. Use "e.Layout.Bands[0]" to get a reference to your band in this event handler.
Thanks for the quick reply.
I have removed the DataMember reference, moved the logic to the InitializeLayout, and I still do not receive any info. I also read over the documentation of valuelist member and tried setting:
c.ValueList.ValueMember = "Id";
still no luck. I think I am probably missing some kind of setting I need to set programatically.
On a parallel note, is it possible to wire up an event on the binding of a row? That way I can force the binding of the dropdown list manually.
Thanks again,
Hi Vince
I have an infragistics grid which is supposed to have a dropdown bound to one of its columns. The grid has a datasource to be bound from the db.
This is what i tried. But no luck
grid.Columns.Add(columnName, columnName);
//Set the column to be a dropdownlist UltraGridColumn Col = grid.Columns.FromKey(columnName);Col.Type = ColumnType.DropDownList;Col.DataType = "System.String";
ValueList ValList = grid.DisplayLayout.Bands[0].Columns.FromKey(columnName).ValueList;ValList.DataSource = listArray;foreach (string item in listArray){ValList.ValueListItems.Add(item);}ValList.DataBind();
advancedmp said:What can you do if you have to load the rows manually?
So, whatever logic you'd normally perform during the InitializeLayout event, you should instead perform after you've added your bands and columns to the grid, and before you add the rows to the grid.
Do you allow editing on your grid? If you don't, then you won't see a dropdown.
Is your WebGrid databound, or are you adding rows to it manually? If you're adding rows manually, then InitializeLayout won't be raised.
You can use the server-side InitializeRow event to handle each row as the grid binds to it, but this won't help in your situation. A ValueList can only be assigned to a column, not to individual cells in that column. Like InitializeLayout, this event is only raised if you're data binding your grid, not when you're adding rows manually.
I'm in a similar situation where I have a grid that I'm adding rows to manually. I have a column that has a databound valuelist, however the values from the DB never show up. As per what you said, since the InitializeLayout event is never raised, it won't databind the valuelist. What can you do if you have to load the rows manually?
One last thought, though it's a "shot in the dark." Try changing this line:
... to this:
List<Class1> cl1 = new List<Class1>();
If this information doesn't help, then I'm not sure what's missing. If this occurs, I suggest that you submit a support request with a sample of what you have so far, so that we can take a closer look.