I have a field I am creating a web image button (template data field), within the grid, which allows them to sign up for a class. It will allow them to proceed to the next page if clicked. I would like to be able to show a label instead of the button if the class is full. Is this possible? I would be getting the "toggle" item from the database (from within the datasource populating the grid). Thanks in advance for your help.
hello, I need help with this also, I am adding the template correctly in the WedDataGrid_InitializeRow event, but after postback it disappears I don't need this template on ever row, only those that have met certain criteria's, how do I handles this after postback?
Hello bpabmeyer,
you can handle InitializeRow event and populate templated column based on some condition. Use Item Template
<ig:WebDataGrid ID="WebDataGrid1" runat="server" Height="350px" Width="400px" AutoGenerateColumns="False" DataSourceID="SqlDataSource1" oninitializerow="WebDataGrid1_InitializeRow"> <Columns> <ig:BoundDataField DataFieldName="ProductID" Key="ProductID"> <Header Text="ProductID" /> </ig:BoundDataField> <ig:BoundDataField DataFieldName="ProductName" Key="ProductName"> <Header Text="ProductName" /> </ig:BoundDataField> <ig:TemplateDataField Key="TemplateField_0"> <Header Text="TemplateField_0" /> </ig:TemplateDataField> </Columns> </ig:WebDataGrid>
protected void WebDataGrid1_InitializeRow(object sender, Infragistics.Web.UI.GridControls.RowEventArgs e) { //check some condition if (e.Row.Items[1].Text == "Chef Anton's Cajun Seasoning") { e.Row.Items[2].Template = new CustomItemTemplate(); } else { e.Row.Items[2].Text = "No avaiable classes"; } } private class CustomItemTemplate : ITemplate { #region ITemplate Members public void InstantiateIn(Control container) { LinkButton edit = new LinkButton(); edit.CssClass = "LinkButton"; edit.Text = "Edit"; edit.OnClientClick = "return editRow()"; LinkButton delete = new LinkButton(); delete.CssClass = "LinkButton"; delete.Text = "Delete"; delete.OnClientClick = "return deleteRow()"; container.Controls.Add(edit); container.Controls.Add(delete); } #endregion }