Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Persist DropDownList values on postback
Message
De
25/11/2004 12:27:16
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
25/11/2004 11:37:17
Nancy Folsom
Pixel Dust Industries
Washington, États-Unis
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Divers
Thread ID:
00964714
Message ID:
00964721
Vues:
15
>I have a DropDownList in a TemplateColumn, sourced from a DataReader. I'm baffled at how to perist the values of the list on PostBack (without just reinstantiating the DataReader).
>
>The DropDownList is operating fine up to that point. It's bound to the correct data, displays the correct text, and changes are correctly captured into the data. But, on PostBack the list is empty.
>
>I've tried various things, but in its current incarnation, the Aspx definition is:
>
<asp:DropDownList id="cboContractors" DataSource = '<%# this.contractors.ContractorsList   ' Value = '<%# TimeSheetsDataSet.Con_ID   ' DataTextField = "Company" DataValueField = "ContractorID" DataBinding="con_id" runat="server">
>
>In code, I do the following when the page is initially loaded, and after the page controls are bound:
>
DropDownList ddl = (DropDownList)(TimeSheetDataGrid.Items[0].FindControl("cboContractors"));
>string s = TimeSheetsDataSet.Con_ID;
>ddl.SelectedValue = s;
>...
>Session["cboContractors"] = TimeSheetDataGrid.Items[0].FindControl("cboContractors");
>
>
>On PostBack, no matter what I've tried, the DropDownList is empty. I've saved the control to a session variable, and I save the class (contractor) that the DataSource (contractors.ContractorsList) comes from. On PostBack, I can restore the session variable to a DropDownList control, and the list is okay. But, as soon as the page is displayed the list is empty.
>
>I'm not sure this is even the right way to go about this. The list is roughly 300 rows. I'd rather thought persisting the list, since it rarely changes between posts was the right way to go. But, for now, I've simply changed things so I always instantiate the list. It's fast, and it works. However, I can see the potential for wanting to actually persist the list instead of reloading the DataReader (especially for DataSet sources). So, does anyone have any tips or cluesticks for me? TIA.

Nancy,
Thinking you've already tried client side caching (afraid to ask this) might it be you forgot binding?
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform