I have a webgrid and add my columns in code-behind. I also have a WebCombo on my page (in the markup) which I would like to add as an EditorControl to one of my columns.. So my problem is that I need to add this EditorControl in code-behind when I create my columns.
I assume that I should do something like
newColumn = new UltraGridColumn("myKey", "myHeader", ColumnType.Custom, "");
newColumn.EditorControlID = myWebCombo.ID;
Correct? I tried doing this but the webcombo is not attached to the column, instead the WebCombo is just displayed on the page outside the grid. I am not sure that the ID is correct.. I tried using ClientID aswell, but doesn't work neither. Any thoughts on this?
Hello,
I think you need to set the type of the column like this
column.Type = ColumnType.Custom;
Regards,
Rado
I made a mistake in my previous post. The WebCombo is not displayed on the page outside the grid, instead it simply disappears.
Anyway, with Rado's suggestion I changed my code to:
newColumn = new UltraGridColumn();
newColumn.Key = "myKey";
newColumn.Type = ColumnType.Custom;
The result is the same! I am able to populate the column with values but there is no WebCombo control in the cells.
Just to let you know I run in to the same issue.
I will investigate it further and I will inform you.
Thank you very much! :)
We have found a resolution for your issue, please check the code below:
//Create a WebCombo
WebCombo combo = new WebCombo("webComboID");
//Add a combo to the Form container.
this.Page.Form.Controls.Add(combo);
//Configure the column.
UltraWebGrid1.Columns[1].Type = ColumnType.Custom;
//The Unique ID is required if you use MasterPages.
UltraWebGrid1.Columns[1].EditorControlID = combo.UniqueID;
Let me know your feedback.
Yes, I have just tired it. Now the webcombo actually appears on the page, but not inside the grid control :(
From the grid control I am now creating a webcombo and adding it to the page's form:
this.Page.Form.Controls.Add(myWebCombo);
I use a master page, so I am adding the webcombo to the column this way:
myColumn.EditorControlID = myWebCombo.UniqueID;
Any other ideas?
I am kind of stuck here :( Radoslav, do you have any additional ideas I can try out?
I finally got it working. I am not sure what made the difference, but I have created a minimal page if anyone is interested:
Mark-up (I've removed the DisplayLayout-element within the grid as it is not relevant in this case):
<html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <title></title></head><body> <form id="form1" runat="server"> <div> <uc:TestGrid runat="server" ID="TestGrid"> </uc:TestGrid> </div> </form></body></html>
Code-behind:
public partial class MyClass : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { TestGrid.SetUp(); } } public class TestGrid : UltraWebGrid { public void SetUp() { // create web combo var wc = new WebCombo("webComboID"); this.Page.Form.Controls.Add(wc); // create column var column = new UltraGridColumn(); column.Key = "wc"; column.Header.Caption = "Test"; column.Type = ColumnType.Custom; column.EditorControlID = wc.ID; Columns.Add(column); // add a row so the grid won't be empty var row = new UltraGridRow(); Rows.Add(row); } }