I have a very simple table with 3 columns; ID (hidden), Quantity, Amount. The point of the grid is to allow users to add a new row, add values and the keeping adding rows with values.
I am programatically creating the grid columns specifying the EditItemTemplate of the columns using a class that implements ITemplate as follows:
| templateColumn = new GridTemplateColumn(); |
| templateColumn.EditItemTemplate = new RadNumericTextBoxTemplate("txtQuantity", "Quantity"); |
| templateColumn.UniqueName = templateColumn.HeaderText = "Quantity"; |
| templateColumn.DataField = "Quantity"; |
| myGrid.MasterTableView.Columns.Add(templateColumn); |
| public class RadNumericTextBoxTemplate : TemplateControlDefaults |
| { |
| protected RadNumericTextBox textBox; |
| string controlname; |
| string bindingName; |
| public RadNumericTextBoxTemplate(string ControlName, string BindingName) |
| { |
| this.controlname = ControlName; |
| if (BindingName != string.Empty) |
| { |
| this.bindingName = BindingName; |
| } |
| } |
| public override void InstantiateIn(System.Web.UI.Control container) |
| { |
| textBox = new RadNumericTextBox(); |
| textBox.ID = this.controlname; |
| textBox.Skin = defaultTextBoxSkinName; |
| textBox.Width = Unit.Pixel(100); |
| container.Controls.Add(textBox); |
| } |
| } |
The rows always need to be in Edit mode, InlIne editing in this case:
| protected void myGrid_ItemDataBound(object sender, GridItemEventArgs e) |
| { |
| if (e.Item is GridDataItem) |
| { |
| e.Item.Edit = true; |
| } |
| } |
How do I make sure that the items are bound to the text boxes? The data source is an IList<myObject> where myObject has the properties to match the columns (ID, Quantity, Amount).
Any help appreciated.