I have a WebDataTree with two templates. I bind the data on the initial page load.
This works fine. My templates contain image buttons. If I click an image button, the data-derived portions of the template disappear. Loading the data during each postback causes other problems.
Is there anyway for this data to persist between postbacks?
Here is my html code:
<asp:Label runat="server" ID="lblCommandName" />
<asp:Label runat="server" ID="lblCommandArgument" />
<ig:WebDataTree ID="wdtCurricula" runat="server" DataMember="CATEGORIES" DataLoadingMessage="Please Wait"
DragDropSettings-AllowDrop="true" DragDropSettings-DragDropMode="Move" OnNodeBound="wdtCurricula_NodeBound"
OnItemCommand="wdtCurricula_ItemCommand">
<DragDropSettings AllowDrop="True" DragDropMode="Move">
</DragDropSettings>
<DataBindings>
<ig:DataTreeNodeBinding DataMember="CATEGORIES" TextField="Category" />
<ig:DataTreeNodeBinding DataMember="REPORTS_LIST" TextField="Display_Name" />
</DataBindings>
<Templates>
<ig:ItemTemplate ID="Template1" runat="server" TemplateID="Template1">
<Template>
<asp:ImageButton ID="ibAddLevel0" runat="server" AlternateText="Add" ToolTip="Add"
CausesValidation="false" CommandArgument="argLevel0" CommandName="AddLevel0"
ImageUrl="~/Images/icons/add_16.png" />
<asp:ImageButton ID="ibEdit" runat="server" AlternateText="Edit Student Score" ToolTip="Edit Student Score"
CausesValidation="false" CommandArgument="something" CommandName="Edit" ImageUrl="~/Images/icons/edit_enabled16x16.png" />
<asp:ImageButton ID="ibRemove" runat="server" AlternateText="Remove Student" ToolTip="Remove student from class."
CausesValidation="false" CommandArgument="something" CommandName="RemoveStudent"
ImageUrl="~/Images/icons/delete_enabled16x16.png" />
<asp:Label runat="server" ID="lblCategory" Text='<%# DataBinder.Eval(((Infragistics.Web.UI.TemplateContainer)Container).DataItem, "Category")%>' />
</Template>
</ig:ItemTemplate>
<ig:ItemTemplate ID="Template2" runat="server" TemplateID="Template2">
<asp:ImageButton ID="ibAddLevel1" runat="server" AlternateText="Add" ToolTip="Add"
CausesValidation="false" CommandArgument="argLevel1" CommandName="AddLevel1"
ImageUrl="~/Images/icons/delete_enabled16x16.png" /><%# DataBinder.Eval(((Infragistics.Web.UI.TemplateContainer)Container).DataItem, "Display_Name") %>
</Templates>
</ig:WebDataTree>
Here is the relevant C# code:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
BindTree();
BindGrid();
}
private void BindTree()
wdtCurricula.DataSource = GetReportsDS();
wdtCurricula.DataBind();
protected void wdtCurricula_NodeBound(object sender, DataTreeNodeEventArgs e)
DataTreeNode thisNode = e.Node;
if (thisNode.Level == 0)
thisNode.TemplateId = Template1.TemplateID;
else
thisNode.TemplateId = Template2.TemplateID;
protected void wdtCurricula_ItemCommand(object sender, DataTreeCommandEventArgs e)
lblCommandName.Text = e.CommandName;
lblCommandArgument.Text = e.CommandArgument.ToString();
Thanks!
Hi jmakuch,
Thank you for posting in our forum.
I would suggest that you try to bind the WebDataTree on each page load and set EnableViewState to "false".
Please let me know if this helps.
Thanks for getting back to me!
Just to be sure I got it right, when you say to setEnableViewState="false", do you mean for the datatree control, or the entire page? I need to maintain a page viewstate on this page, so the latter is not an option for me.
Also, if I rebind the WebDataTree on each postback, it appears that the ItemCommand event for the WebDataTree is not triggered when I click my linkbutttons in the tree which are in my template.
Is there a way to maintain the data and also be able to capture clicking of the linkbuttons in the WebDataTree on postback?