Hi Jed,
Thanks for the response.
I've performed some further test through your code behind (and the ascx
template in former message). Since I haven't the complete code and
reference library, I comment out some busness logic specific class code.
Here is my test usercontrol's code(ascx remain the same, only add a
sqldatasource control for testing). Also, I disabled the ViewState of the
usercontrol through @Control directive like:
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="CUUC.ascx.cs"
Inherits="UserControls_CUUC"
EnableViewState="false" %>
And seems the control still works well without any viewstate error on
postback.
=========modified codebehind=============
public partial class UserControls_CUUC : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
}
//private SP_GetSearchListsByBasic _dataSource;
//private DataTable
// public SP_GetSearchListsByBasic ControlDataSource
// {
// get
// {
// if (_dataSource == null)
// {
// _dataSource = SP_GetSearchListsByBasic.Execute(new
//SP_GetSearchListsByBasic.Criteria(this.BasePage.DealerInfo.DealerId));
// }
// return _dataSource;
// }
// }
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
InitializeControl();
this.SearchButton.Click += new EventHandler(SearchButton_Click);//
protected override void OnApplyStyle(object sender, EventArgs e)
// {
// if (this.DefaultCss == string.Empty)
// {
// this.DefaultCss =
//"Default.css";
// };
// base.OnApplyStyle(sender, e);
// }
}
private void SearchButton_Click(object sender, EventArgs e)
{
string status = this.UsedNewDropDownList.SelectedValue;
string manufacturerId = this.ManufacturerDropDownList.SelectedValue;
string typeId = this.TypeDropDownList.SelectedValue;
DoSearch(status, int.Parse(manufacturerId),
int.Parse(typeId));
}
private void DoSearch(string status, int manufacturerId, int typeId)
{
// string url = this.ResolveUrl(ConfigSettings.SearchResultsPage);
// if (status.Length > 0)
// {
// url =
this.BasePage.Website.ChangeQueryStringParameterValue(url,
//QueryStringNames.Instance.Status, status);
// }
// if (manufacturerId > 0)
// {
// url =
this.BasePage.Website.ChangeQueryStringParameterValue(url,
//QueryStringNames.Instance.ManufacturerId, manufacturerId.ToString());
// }
// if (typeId > 0)
// {
// url =
this.BasePage.Website.ChangeQueryStringParameterValue(url,
//QueryStringNames.Instance.TypeId, typeId.ToString());
// }
// Response.Redirect(url);
}
private void InitializeControl()
{
InitializeSearchPanel();
}
private void InitializeSearchPanel()
{
FillNewUsed(this.UsedNewDropDownList);
FillManufacturers(this.ManufacturerDropDownList);
FillRvTypes(this.TypeDropDownList);
}
private void FillNewUsed(ListControl listControl)
{
if (listControl.Items.Count == 0)
{
listControl.Items.Clear();
listControl.Items.Add(new ListItem("New and Used", "Any"));
listControl.Items.Add(new ListItem("New Only", "New"));
listControl.Items.Add(new ListItem("Used Only", "Used"));
}
// if
//(listControl.Items.FindByValue(this.BasePage.Website.QueryString.Status)
!=
//null)
// {
// listControl.SelectedValue =
//this.BasePage.Website.QueryString.Status;
// }
}
private void FillManufacturers(ListControl listControl)
{
if (listControl.Items.Count == 0)
{
listControl.Items.Clear();
listControl.DataTextField = "CategoryName";
listControl.DataValueField = "CategoryID";
listControl.DataSource = this.SqlDataSource1;
listControl.DataBind();
listControl.Items.Insert(0, new ListItem("Choose Manufacturer",
"0"));
}
// if
//(listControl.Items.FindByValue(this.BasePage.Website.QueryString.Manufactu
rerId.ToString()) != null)
// {
// listControl.SelectedValue =
//this.BasePage.Website.QueryString.ManufacturerId.ToString();
// }
}
private void FillRvTypes(ListControl listControl)
{
if (listControl.Items.Count == 0)
{
listControl.Items.Clear();
listControl.DataTextField = "CategoryName";
listControl.DataValueField = "CategoryID";
listControl.DataSource = this.SqlDataSource1;
listControl.DataBind();
listControl.Items.Insert(0, new ListItem("Choose RV Type",
"0"));
}
// if
//(listControl.Items.FindByValue(this.BasePage.Website.QueryString.TypeId.To
String()) != null)
// {
// listControl.SelectedValue =
//this.BasePage.Website.QueryString.TypeId.ToString();
// }
}
}
==========================
Regards,
Steven Cheng
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Get Secure!
www.microsoft.com/security (This posting is provided "AS IS", with no warranties, and confers no
rights.)