[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 240
  • Last Modified:

Question about populating and postback

If I am populating my Radiobuttonlist like this below, does this mean even on every postback, the Radiobuttonlist is being re-populated (Hitting the server each time)?
<asp:RadioButtonList ID="rdoIntroRebuttals" runat="server" AutoPostBack="True"  Font-Size="12pt" TabIndex="7" ForeColor="Black" DataSourceID="XmlDataSourceRebuttals" DataTextField="Name" DataValueField="Value">
        </asp:RadioButtonList>
 <asp:XmlDataSource ID="XmlDataSourceRebuttals" runat="server"  DataFile="~/App_Data/xmlRebuttalsList.xml"></asp:XmlDataSource>

And, if it is being re-populated on every postback, is there a way to populate this radiobuttonlist from code behind instead, using a If Not Page.IsPostBack Then statement so that it does not re-populate on postback calls? Thanks.

0
John Account
Asked:
John Account
  • 3
  • 2
1 Solution
 
60MXGCommented:
yes!  Every time you select a different value from the radiobutton list, the code will send that change back to the server.
0
 
nmarunCommented:
You could try:

<asp:RadioButtonList ID="rdoIntroRebuttals" runat="server" AutoPostBack="True"  Font-Size="12pt" TabIndex="7" ForeColor="Black" DataTextField="Name" DataValueField="Value">
        </asp:RadioButtonList>
 <asp:XmlDataSource ID="XmlDataSourceRebuttals" runat="server"  DataFile="~/App_Data/xmlRebuttalsList.xml"></asp:XmlDataSource>
 
//code behind
 
if(!ispostback)
{
   rdoIntroRebuttals.DataSourceID = XmlDataSourceRebuttals;
   rdoIntroRebuttals.DataTextField = "Name";
   rdoIntroRebuttals.DataValueField = "Value";
   rdoIntroRebuttals.DataBind();
}

Open in new window

0
 
John AccountAuthor Commented:
nmarun, Getting an error that says Name 'XmlDataSourceRebuttals' is not declared.
Should I change XmlDataSourceRebuttals to Xmldatasourceview?
0
NEW Veeam Backup for Microsoft Office 365 1.5

With Office 365, it’s your data and your responsibility to protect it. NEW Veeam Backup for Microsoft Office 365 eliminates the risk of losing access to your Office 365 data.

 
nmarunCommented:
Sorry change that to:
rdoIntroRebuttals.DataSource = XmlDataSourceRebuttals;
0
 
John AccountAuthor Commented:
Oh...that is super great, Nmarun. Thank you so much--I've learned alot from you here with this question you answered! And, now my application is running much faster, too. Many thanks!
0
 
John AccountAuthor Commented:
Your help was very much appreciated, nmarun. Mega thanks!
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now