Is it possible to assign a specific custom editor control to a specific cell?
Example:
row 1
column 2 set to datetimechooser
row 2
column 2 set to textbox
row 3 column 2 set to dropdown combo..
is this possible? If it isn't, then is there another asp.net grid that can be done like this?
Hello Daryl,
Basically we have implemented "out of the box " editors for the grids / WebDataGrid / UltraWebGrid / but they are based on column level means that a particular editor is attached to a specified column. In this case I think that you will be able to achieve your goal as you use template columns and for example on InitializeRow even to get access to desired row / cell and put whatever controls you like.
I wold suggest look at the samples here: http://samples.infragistics.com/2009.2/WebFeatureBrowser/Default.aspx = > ASP.NET (AJAX Enabled = > WebGrid ).
Please refer this link for "how to" use Template column in context of UltraWebGrid Template Columns
Thank you .
si is it possible to have a editor control1 for row1,column1 and editorcontrol2 for row,column2?
See what I am driving at? This can be done on the winforms grid.
As far as I know for our ASP.NET grids this can't be implemented "out of the box" /just to set a property/ as I already mentioned you have a chance to accomplish this in InitializeRow event of the grid like so:
Register the InitializeRow handler
13 protected void Page_Load(object sender, EventArgs e)
14 {
15 UltraWebGrid1.InitializeRow +=
16 new InitializeRowEventHandler(UltraWebGrid1_InitializeRow);
17 if (Session["data"] == null) {
18
19 Session["data"] = MakeTable();
20 }
21 }
The implementation goes here:
d
23 void UltraWebGrid1_InitializeRow(object sender, RowEventArgs e)
24 {
25 if (e.Row.IsAlternate())
26 {
27 TemplatedColumn tColumn =
28 (TemplatedColumn)((UltraWebGrid)sender)
.Columns.FromKey("ColTemplate");
29 tColumn.CellTemplate = new CustomButtonTemplate();
30 }
31 else
32 {
33 TemplatedColumn tColumn =
34 (TemplatedColumn)((UltraWebGrid)sender)
35 tColumn.CellTemplate = new CustomCheckBoxTemplate();
36 }
37 }
The Template Implementation :
183 //Create button template
184 private class CustomButtonTemplate : ITemplate
185 {
186 //This is the handler for button click Event.
187 void buttonClickHandler(object sender, EventArgs args)
188 {
189 string test = "";
190 }
191
192 //Here you can put whatever control you want.
193 public void InstantiateIn(Control container)
194 {
195 Button button = new Button();
196 //Create handler for button click
197 button.Click += new EventHandler(buttonClickHandler);
198 button.Text = "edit";
199 container.Controls.Add(button);
200 }
201 }
202
203 //Create checkbox template
204 private class CustomCheckBoxTemplate : ITemplate
205 {
206 //Here you can put whatever control you want.
207 public void InstantiateIn(Control container)
208 {
209 CheckBox checkBox = new CheckBox();
210 checkBox.Text = "edit";
211 container.Controls.Add(checkBox);
212 }
213 }
Hope this helps you go ahead with your requirement.
Thank you
Hi Daryl,
Just wanted to show you the result in the grid: