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,
can you attach your markup here please.
Thanks.
i want adding combos into cells but every cell can having different values in column
how ? ..
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); } }
I am kind of stuck here :( Radoslav, do you have any additional ideas I can try out?
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?