jimwal1940
asked on
EnableViewState = False causes items not to write to database
I was building an application that queries a database to populate 10 pulldowns. One issue is that each of these 10 dropdowns has about 5000 drug names in each one. I was getting a " Maximum Request Length Exceeded" but was adviced to turn off view state on each drop down so I did and it seemed to allow the record to write. I just found out though that those dropdowns that I made EnableViewState = false aren't writting or being placed into the array variables to be written to the database... When I make EnableViewState = True they are assigned to the variales but since the Event Viewis so long I continue to get the above error...
Thoughts Any one ?????
Thoughts Any one ?????
ASKER
SO Saddy currently I have the dropdowns that get populated via a database table.... and load the selections into an array such as this ...
values.Add(drp_meds1.Selec tedValue);
values.Add(drp_meds2.Selec tedValue);
values.Add(drp_meds3.Selec tedValue);
values.Add(drp_meds4.Selec tedValue);
values.Add(drp_meds5.Selec tedValue);
values.Add(drp_meds6.Selec tedValue);
values.Add(drp_meds7.Selec tedValue);
values.Add(drp_meds8.Selec tedValue);
values.Add(drp_meds9.Selec tedValue);
values.Add(drp_meds10.Sele ctedValue) ;
What would the code look like in your solution ?
values.Add(drp_meds1.Selec
values.Add(drp_meds2.Selec
values.Add(drp_meds3.Selec
values.Add(drp_meds4.Selec
values.Add(drp_meds5.Selec
values.Add(drp_meds6.Selec
values.Add(drp_meds7.Selec
values.Add(drp_meds8.Selec
values.Add(drp_meds9.Selec
values.Add(drp_meds10.Sele
What would the code look like in your solution ?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If you switch off viewstate, then you must reconstruct the dropdownlist across every postback and obtain the data of the dropdownlist from the RequestForm collection.
The proper way to get this is the following:
// get the name via the UniqueID property, the same would generally apply for controls inside UserControls
// if the controls are inside any control implementing the INamingContainer, then the property will not be accurate in giving the name for retrieval.
string name = ddl.UniqueID;
string value = Request.Form[name] == null ? string.Empty : Request.Form[name];
The proper way to get this is the following:
// get the name via the UniqueID property, the same would generally apply for controls inside UserControls
// if the controls are inside any control implementing the INamingContainer, then the property will not be accurate in giving the name for retrieval.
string name = ddl.UniqueID;
string value = Request.Form[name] == null ? string.Empty : Request.Form[name];
// if the controls are inside any control implementing the INamingContainer, then the property will not be accurate in giving the name for retrieval. <-- will not apply to controls found imemdiately inside the UserControl
--saddy1--