Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
50
ig:WebHierarchicalDataGrid - Template column invisible after postback
posted

Hi support team, 

After a post back, the items in column template are invisible. I don't find anyway to keep it visible after post back. 

Please see my example code: 

1. ASPX: 

<body>
<form id="form1" runat="server">
<ig:WebScriptManager ID="WebScriptManager1" runat="server">
</ig:WebScriptManager> 
<ig:WebHierarchicalDataGrid ID="WebHierarchicalDataGrid1" runat="server" Height="350px" Width="400px" 
EnableDataViewState="True" > 
</ig:WebHierarchicalDataGrid>
<asp:Button ID="buttonTest" runat="server" Text="Test" OnClick="buttonTest_Click" />
</form>
</body>

2. .ASPX.CS

protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
DataTable table = new DataTable();
table.Columns.Add("userid", typeof(string));
table.Columns.Add("name", typeof(string));
table.Columns.Add("city", typeof(string));
table.Rows.Add("1", "peter", "us");
table.Rows.Add("2", "john", "uk");
DataSet ds = new DataSet();
ds.Tables.Add(table);
WebHierarchicalDataGrid1.AutoGenerateColumns = true;
WebHierarchicalDataGrid1.DataSource = ds;
WebHierarchicalDataGrid1.RowIslandDataBinding += new RowIslandEventHandler(WebHierarchicalDataGrid1_RowIslandDataBinding);
WebHierarchicalDataGrid1.DataBind();
}
}

private void WebHierarchicalDataGrid1_RowIslandDataBinding(object sender, RowIslandEventArgs e)
{
TemplateDataField field1 = new TemplateDataField();
field1.Key = "TemplateColumn1";
field1.Header.Text = "Edit";
field1.ItemTemplate = new CustomItemTemplate1(); 
WebHierarchicalDataGrid1.Columns.Add(field1);
}

public class CustomItemTemplate1 : ITemplate
{
public void InstantiateIn(Control container)
{
TextBox vText = new TextBox();
vText.Text = "test";
vText.ID = "test";
vText.EnableViewState = true;
container.Controls.Add(vText); 
}
}

protected void buttonTest_Click(object sender, EventArgs e)
{
// do nothing
}

Could you please help? 

Thanks,

Uy

Parents
No Data
Reply Children
No Data