-
July 7th, 2009, 01:35 PM
#1
AppendDataBoundItem
I used AppendBoundItem in dropdown -but it keeps on adding extra list of data everytime I click
does any one have any idea how to restrict it.
thanks here's the code:
Code:
<asp:ObjectDataSource ID="SrcCty" runat="server"
OldValuesParameterFormatString="original_{0}" SelectMethod="GetData"
TypeName="stateTableAdapters.CityTableAdapter" >
<SelectParameters>
<asp:ControlParameter ControlID="ddlSt" Name="MyState"
PropertyName="SelectedValue" Type="String" DefaultValue="null" />
<asp:ControlParameter ControlID="RBl1" Name="mytype"
PropertyName="SelectedValue" Type="String" />
<asp:ControlParameter ControlID="ddlyr" Name="FromYear"
PropertyName="SelectedValue" Type="Decimal" />
<asp:ControlParameter ControlID="ddlTo" Name="ToYear"
PropertyName="SelectedValue" Type="Decimal" />
</SelectParameters>
</asp:ObjectDataSource>
CITY:
<asp:DropDownList ID="ddlCity" runat="server" DataSourceID="SrcCty"
DataTextField="CITY" DataValueField="STATE_COUNTRY_CODE" OnInit="ddlcity_Init" AppendDataBoundItems="true">
<asp:ListItem Text="" Value="0" Enabled="false"></asp:ListItem>
</asp:DropDownList>
-
July 8th, 2009, 07:41 AM
#2
Re: AppendDataBoundItem
I think if you set the AppendDataBoundItem attribute in the dropdownlist to false, the repetition of the data could be stopped. You may also try setting the atributes in the Page.Ispostback method. eg.
if(!Page.IsPostback)
{
ddlCity.DataSource=SrcCty;
ddlCity.DataBind();
}
-
July 8th, 2009, 10:43 AM
#3
Re: AppendDataBoundItem
I tried but got an error meassage
Server Error in '/hits' Application.
--------------------------------------------------------------------------------
Both DataSource and DataSourceID are defined on 'ddlCity'. Remove one definition.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: Both DataSource and DataSourceID are defined on 'ddlCity'. Remove one definition.
Source Error:
Line 33: {
Line 34: ddlCity.DataSource = SrcCty;
Line 35: ddlCity.DataBind();
Line 36:
Line 37: //SrcCty.SelectParameters["myState"].DefaultValue = ddlSt.SelectedValue;
Source File: c:\hits\Search.aspx.cs Line: 35
Stack Trace:
[InvalidOperationException: Both DataSource and DataSourceID are defined on 'ddlCity'. Remove one definition.]
System.Web.UI.WebControls.DataBoundControl.ConnectToDataSourceView() +8554773
System.Web.UI.WebControls.DataBoundControl.GetData() +4
System.Web.UI.WebControls.ListControl.OnDataBinding(EventArgs e) +24
System.Web.UI.WebControls.ListControl.PerformSelect() +34
System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +73
Search.Page_Load(Object sender, EventArgs e) in c:\hits\Search.aspx.cs:35
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +50
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.3082; ASP.NET Version:2.0.50727.3082
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|