Hi,
We have a requirement to have webgrid with bound to data source and unbound templated column with text boxes.These are my requirements in addition to other validations on other textboxes etc.
This is how I am creating templated column with text box.
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
AddGridTemplatedColumns();
}
protected override void OnInit(EventArgs e)
base.OnInit(e);
UltraWebGrid1.InitializeDataSource += new Infragistics.WebUI.UltraWebGrid.InitializeDataSourceEventHandler(UltraWebGrid1_InitializeDataSource);
void UltraWebGrid1_InitializeDataSource(object sender, Infragistics.WebUI.UltraWebGrid.UltraGridEventArgs e)
//throw new Exception("The method or operation is not implemented.");
DataTable dt = new DataTable("Customer");
dt.Columns.Add("CustomerID", typeof(int));
dt.Columns.Add("CustomerName", typeof(string));
dt.Columns.Add("Address", typeof(string));
dt.Rows.Add(new object[ { 1, "John Lever", "South Street" });
dt.Rows.Add(new object[ { 2, "Walter Smith", "12/4 S MarkD" });
dt.Rows.Add(new object[ { 3, "Kathy Lever", "23/45 Honai" });
dt.Rows.Add(new object[ { 4, "George Wills", "233 Walter Street" });
UltraWebGrid1.DataSource = dt;
protected void UltraWebGrid1_InitializeLayout(object sender, Infragistics.WebUI.UltraWebGrid.LayoutEventArgs e)
e.Layout.Bands[0].Columns.FromKey("TemplatedColumn").Move(3);
private class PlaceTemplate : ITemplate
public void InstantiateIn(System.Web.UI.Control container)
CellItem cellitem = ((CellItem)(container));
TextBox btn = new TextBox();
btn.ID = "txtBox";
btn.Width = 85;
btn.EnableViewState = false;
cellitem.Controls.Add(btn);
private void AddGridTemplatedColumns()
// add an unbound columns
TemplatedColumn colHoldings;
colHoldings = new TemplatedColumn();
colHoldings.Key = "TemplatedColumn";
colHoldings.HeaderText = "Amount";
PlaceTemplate temp = new PlaceTemplate();
colHoldings.CellTemplate = temp;
UltraWebGrid1.Bands[0].Columns.Insert(UltraWebGrid1.Bands[0].Columns.Count, colHoldings);
protected void UltraWebGrid1_TemplatedColumnRestored(object sender, Infragistics.WebUI.UltraWebGrid.ColumnEventArgs e)
if (e.Column.Key == "TemplatedColumn")
if (((TemplatedColumn)e.Column).CellTemplate == null)
((TemplatedColumn)e.Column).CellTemplate = new PlaceTemplate();
I tried to follow the code used in this articles:
http://devcenter.infragistics.com/Support/KnowledgeBaseArticle.aspx?ArticleID=3467
But it is for regular column. So, not able to use it for templated column footer.
I appreciate your response.
Thanks,
Prathiba