Hi,
I am trying to use InitializeLayout event but it doesn´t work when the DataSource is not set.
Is it a bug or the DataSource must be always set?
Tks,
Duan Brito
Hello,
Not sure if this is a bug - I think that this might be bt design, since if there is no datasource the InitializeXXX events do not really play role in the grid (like InitializeRow, InitializeDataSource, InitializeLayout).
Do you need to use the grid in unbound mode? Then you can just custmoze the Layout of the grid immediately prior to populating it with data - in the same event where you are populating the grid with data (I assume, Page_Load). Will this work in your scenario?
Rumen Stankov,
How can I do this?
Because I want to show to the user a dropdownlist with the options they can choose and after I'll save the ID of the option on the database.
This work fine.
Thank you very much.
Yes, sure - but unless I am missing something obvious, just replacing e.Layout with UltraWebGrid1.DisplayLayout (if the ID of the grid is UltraWebGrid) in the code will work just fine and you will not need InitializeDataSource at all - just running this code will solve the problem.
Please, excuse me once again if I am missing something obvious.
Sorry, I think I haven't been clear enougth. Let's try again.
I need to add a dropdownlist in a column off my grid. First I just change the type propertie to dropdownlist and on InitializeLayout event I wrote this code:
e.Layout.Bands[0].Columns.FromKey("sale_unit").Type = Infragistics.WebUI.UltraWebGrid.ColumnType.DropDownList;
IList ilSaleUnit= new SaleUnitDAO().list();
lstSaleUnit.DataSource = ilSaleUnit;
lstSaleUnit.DataBind();
e.Layout.Bands[0].Columns.FromKey("sale_unit").DefaultValue = new SaleUnitDAO().getID("UN");
But doesn´t work when the uwg's DataSource is not set, the InitializeLayout event doesn't fire and the cell stay blank. I would like to point out the fact that I do not want the uwg's DataSource to be set.
If anyone has a solution, let me know how to do it step by step, please.
Hello Duan,
Well, from what I can tell from this scenario you can have the layout custmozition code in the SelectedIndexChanged event of the dropdownlist and first set the layout of the grid based on the selection and then populate it with data.