S
SevDer
Hi,
I have 1 parent user control and 4 child user controls inside that.
the last user control has problems with viewstate.
I have 4 dropdowns in this user control where I bind them from code behind
as follows:
private void Page_Load(object sender, System.EventArgs e)
{
if (!IsPostBack)
{
BindStaticControls();
}//end if
}//end Page_Load method
private void BindStaticControls()
{
//Billing state dropdown
ddState.DataSource = statesDataTable;
ddState.DataTextField = "StateName";
ddState.DataValueField = "StateCode";
ddState.DataBind();
//Shipping state dropdown
ddSState.DataSource = statesDataTable;
ddSState.DataTextField = "StateName";
ddSState.DataValueField = "StateCode";
ddSState.DataBind();
//Billing country dropdown
ddCountry.DataSource = countriesDataTable;
ddCountry.DataTextField = "CountryName";
ddCountry.DataValueField= "CountryCode";
ddCountry.DataBind();
ddCountry.EnableViewState = true;
}
1. In a postback all the content of these dropdowns are lost.
2. In ascx page for testing, for some of them I put explicit attriubtes as
in the following code lines
Example1: <aspropDownList id="ddSCountry" CssClass="lit"
runat="server" DataSource='<%# countriesDataTable %>'
DataValueField="CountryCode" DataTextField="CountryName"></aspropDownList>
Example2:
<aspropDownList id="ddCountry" CssClass="lit" runat="server"
EnableViewState="True"></aspropDownList>
Example3:
<aspropDownList id="ddSState" CssClass="lit"
runat="server"></aspropDownList>
And in the trace, the viewstate size for these dropdowns are always 0. So I
cannot set the viewstate for it. And I really don't know why!
As you will see from the code behind code, I explicitly enable viewstate too
but it doesn't help as the others.
So for the last step I extended my approach to set enableViewState="True" in
<%@ Control> tag
This problem drove me crazy for the last 4 hours and I and my friends cannot
find a solution for this.
Please help ASAP, or I will go crazy.
Best regards,
SevDer
I have 1 parent user control and 4 child user controls inside that.
the last user control has problems with viewstate.
I have 4 dropdowns in this user control where I bind them from code behind
as follows:
private void Page_Load(object sender, System.EventArgs e)
{
if (!IsPostBack)
{
BindStaticControls();
}//end if
}//end Page_Load method
private void BindStaticControls()
{
//Billing state dropdown
ddState.DataSource = statesDataTable;
ddState.DataTextField = "StateName";
ddState.DataValueField = "StateCode";
ddState.DataBind();
//Shipping state dropdown
ddSState.DataSource = statesDataTable;
ddSState.DataTextField = "StateName";
ddSState.DataValueField = "StateCode";
ddSState.DataBind();
//Billing country dropdown
ddCountry.DataSource = countriesDataTable;
ddCountry.DataTextField = "CountryName";
ddCountry.DataValueField= "CountryCode";
ddCountry.DataBind();
ddCountry.EnableViewState = true;
}
1. In a postback all the content of these dropdowns are lost.
2. In ascx page for testing, for some of them I put explicit attriubtes as
in the following code lines
Example1: <aspropDownList id="ddSCountry" CssClass="lit"
runat="server" DataSource='<%# countriesDataTable %>'
DataValueField="CountryCode" DataTextField="CountryName"></aspropDownList>
Example2:
<aspropDownList id="ddCountry" CssClass="lit" runat="server"
EnableViewState="True"></aspropDownList>
Example3:
<aspropDownList id="ddSState" CssClass="lit"
runat="server"></aspropDownList>
And in the trace, the viewstate size for these dropdowns are always 0. So I
cannot set the viewstate for it. And I really don't know why!
As you will see from the code behind code, I explicitly enable viewstate too
but it doesn't help as the others.
So for the last step I extended my approach to set enableViewState="True" in
<%@ Control> tag
This problem drove me crazy for the last 4 hours and I and my friends cannot
find a solution for this.
Please help ASAP, or I will go crazy.
Best regards,
SevDer