Last post Aug 12, 2017 05:22 PM by a2h
Aug 12, 2017 03:57 PM|RobertH3|LINK
I am not sure if this is the right forum, but a simple question about databinding.
If I have a page with 40 panels, but not all are visible or will be (maybe an average of 2 to 5 will be) yet each Panel has 2 datacontrols and 2 datasources, do these datacontrols still get bound to their sources even though the panel is not visible. If
it does, this would slow things down even though the data would be empty, how would I bypass this?
Do I Enabled=false each datacontrol and datasource unless I need them?
<asp:Panel ID = "panel1" Visible = "false" >
<asp:ListView ID = "ListView" ></asp:ListView>
<asp:Panel ID = "panel2" Visible = "false" >
<asp:Panel ID = "panel3" Visible = "false" >
If result = 1 then Panel1.Visible = true;
If result = 2 then Panel2.Visible = true;
If result = 3 then Panel3.Visible = true;
If result = 4 then Panel1.Visible = true; Panel2.Visible = true;
and so on for multiple combinations.
The use is for a SalesQuote for services, each page has separate data for separate services, but not every sales quote will contain data for the same services. So I can make 50 separate webpages for each service, which would be inconvenient in printing 10
pages for a client that wants quotes for 10 services, or create a single page that can detect only those services and display only those pages - I just dont want to burden things down with 100 Datacontrols and Datasources if I will only be displaying 8 if
they do bind even though the Panel they are in is not visible
Aug 12, 2017 05:22 PM|a2h|LINK
do these datacontrols still get bound to their sources even though the panel is not visible.
AFAIK when you set a control Visible to false, the control wont even render in page at runtime. Hence the Listview control inside hidden panels wont get bound with data at runtime.
See the below html
<asp:Panel ID="Panel2" runat="server" Visible="false">
Visible False Panel
<asp:TextBox ID="TextBox11" runat="server"></asp:TextBox>
<asp:Panel ID="Panel3" runat="server">
Visible True Panel
<asp:TextBox ID="TextBox13" runat="server"></asp:TextBox>
<asp:TextBox ID="TextBox12" runat="server"></asp:TextBox>
if you see the generated html using ViewSource option in IE, we can see that Panel2 wont get rendered as div at runtime. However since Panel3 Visible property is set as true, Panel 3 will be rendered.
Visible True Panel
<input name="TextBox13" type="text" id="TextBox13" />
<input name="TextBox12" type="text" id="TextBox12" />