Is it possible to assign editors to different cells in the code behind at run time?
Do you have a web version of the Infragistics.Win.UltraWinGrid?
Or something similar? I need to replicate a windows forms function on the web.
Specifically I need to iterate through a datagrids rows collection and assign types to cells.
Simliar to
For Each r As Infragistics.Win.UltraWinGrid.UltraGridRow In ParameterGrid.Rows r.Cells("PromptText").Value = r.Cells("ParameterFieldName").Text 'Initialize the ValueList Dim idx As Integer = CInt(r.Cells("CurrentValues").Value) r.Cells("CurrentValues").Value = String.Empty i = CType(valuelistdata(idx), Object()) Dim pType As FieldValueType = CType([Enum].Parse(GetType(FieldValueType), r.Cells("ParameterType").Text), FieldValueType) Select Case pType Case FieldValueType.DateField r.Cells("CurrentValues").Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownCalendar r.Cells("CurrentValues").Value = DateTime.Now Case FieldValueType.DateTimeField r.Cells("CurrentValues").Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DateTime r.Cells("CurrentValues").Value = DateTime.Now Case FieldValueType.BooleanField r.Cells("CurrentValues").ValueList = m_vBoolean
Hi Daryl,
The ASP.Net version of the WinGrid is the WebGrid or also called UltraWebGrid. However, the WebGrid is not an exact replica of the WinGrid. Some functionalities are possible in one but not in the other grid due to the difference in the technologies/platforms and their own complexities.
It is not possible to have different cells with different DataTypes in the WebGrid so you cannot assign different editors to different cells. The datatype is assigned on the entire column as shown below :-
protected void UltraWebGrid1_InitializeLayout(object sender, Infragistics.WebUI.UltraWebGrid.LayoutEventArgs e){ e.Layout.Bands[0].Columns.FromKey("EmployeeID").DataType = "System.Int32"; }
However if you need to have different ValueLists on different rows, this is possible in the WebGrid. Please see the below link :-
http://help.infragistics.com/NetAdvantage/ASPNET/2010.1/CLR3.5/?page=WebGrid_Changing_ValueLists_on_a_Per_Row_Basis.html
Thanks for you input. Howevre I would beg to differ with your statement.
I agree that it is not possible to do this in the same fashion as the wingrid.It is possible and I have done it by using template columns and i can assign a different type of edit control to an individual cell in a column.. So, in fact, Row 1 column 1 can have a datetime control and row2 column1 can have a textedit control. So to say it is not possible would be incorrect.
I would be happy to share with you a sample project that is complete and does exactly what I have said. I spent a considerable amount of time trying to do this using dynamically created controls. and figured out that adding a number of controls to a cell template and then just showing the ones i needed works perfectly.
ps. and the control of the webgrid and template controls is all done on the server.
Thanks for the update. You are absolutely correct. With templated columns you can have different controls inside them like DateTimeEdit controls and TextEdit controls as you suggested. I was looking for a more direct approach like the one in WinGrid which isnt possible. If you have a sample project for this, please kindly attach it to this post. It would certainly benefit many of our other customers too.
Thanks very much !
Thanks for posting the sample project. It will certainly benefit anyone who requires this functionality.
Here is the sample project..
For size reason I removed the ig_res directory.