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.
Hi,
The code below works for me.
UltraGridColumn newColumn; newColumn = new UltraGridColumn(); newColumn.Key = "myKey"; newColumn.Type = ColumnType.Custom; newColumn.EditorControlID = WebCombo1.ID;
//Add your column to the collection. UltraWebGrid1.Columns.Add(newColumn);
If you still have a problems I will send you a sample.
I have the same code as you but it's still not working. Is it possible that it has something to do with the fact that I use a master page on my page? I've read somewhere that the presence of a master page means that the IDs of the controls on the page are changed somehow... How do I check that the TaskGrid uses the correct ID?
Radoslav, could you send me the sample that you mention?
Please find the attached sample.
Just take a look at the method :
//Create a column
void createColumn() {
//Create a column.
UltraGridColumn col1 = new UltraGridColumn(true);
col1.Header.Caption = "Column with WebCombo";
col1.Key = "r1";
col1.Type = ColumnType.Custom;
col1.EditorControlID = WebCombo1.ID;
//Add column to the collection
UltraWebGrid1.Columns.Add(col1);
}
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?