0

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:

<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>
3
Contributors
16
Replies
17
Views
7 Years
Discussion Span
Last Post by selvam543
0

I tried in "INit"
here's the code thanks

protected void ddlcity_Init(object sender, EventArgs e)
        {
            
                       
            ddlCity.Items.Insert(0, new ListItem("---", string.Empty));

        }
        
 public void MakeSQL()
        {

            sSQL += "AND RECORD_TYPE ='" + RBl1.SelectedValue.ToString() + "'";

            Lbl1.Text = sSQL;
        }
        protected void ddlCity_SelectedIndexChanged(object sender, EventArgs e)
        {
           
            
            sSQL += "AND CITY='" + ddlCity.SelectedValue.ToString() + "'";
            lblmsg.Text = sSQL;
            MakeSQL();
        }
0
<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="~/Search.aspx.cs" Inherits="Search" MasterPageFile="~/hits_main.master"%>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<asp:ScriptManager ID="ScrptMgr1" runat="server"></asp:ScriptManager>
<div>
<asp:UpdatePanel runat="server" ID="Up1">
<ContentTemplate>
    <table  cellspacing="10" border=".02">   
    <tr>   
      <td   align="left"  > 
          <asp:RadioButtonList ID="RBl1" runat="server" AutoPostBack="True"                               
                                CellPadding="2" CellSpacing="5" 
              onselectedindexchanged="RBl1_SelectedIndexChanged">
            <asp:ListItem  Value="G" Selected="True" >Regular Grants</asp:ListItem>
           <%-- <asp:ListItem Value ="A">ARRA Grants</asp:ListItem>--%>
            <asp:ListItem Value ="C">Contract</asp:ListItem>
            </asp:RadioButtonList>                 
         
         </td>
        
         <td>
          <asp:ObjectDataSource ID="Srcfmyr" runat="server" 
                 OldValuesParameterFormatString="original_{0}" SelectMethod="GetData" 
                 TypeName="HITS.App_code.stateTableAdapters.SOURCE_YEAR_VWTableAdapter">                 
                 <SelectParameters>
                     <asp:ControlParameter ControlID="RBl1" Name="myType" 
                         PropertyName="SelectedValue" Type="String" DefaultValue="G" />
             </SelectParameters>
             </asp:ObjectDataSource>
           From: <asp:DropDownList ID="ddlyr" runat="server"
                     OnSelectedIndexChanged="ddlyr_SelectedIndexChanged"    
                AutoPostBack="True" DataSourceID="Srcfmyr" 
                DataTextField="SOURCE_YEAR"              
                DataValueField="SOURCE_YEAR"  Font-Underline="False" >
            </asp:DropDownList>&nbsp; &nbsp; &nbsp; 
              
          <asp:ObjectDataSource ID="SrcToyr" runat="server" 
                 OldValuesParameterFormatString="original_{0}" SelectMethod="GetData" 
                 TypeName="HITS.App_code.stateTableAdapters.SOURCE_YEAR_VWTableAdapter">
                 <SelectParameters>
                     <asp:ControlParameter ControlID="RBl1"
                      DefaultValue="G" Name="myType" 
                         PropertyName="SelectedValue" 
                         Type="String" />
                 </SelectParameters>
            </asp:ObjectDataSource>
             <asp:Label ID="lblTo" runat ="server" Text="To:"></asp:Label>
            <asp:DropDownList ID="ddlTo" runat="server"   
                AutoPostBack="True" DataSourceID="Srcfmyr" 
                DataTextField="SOURCE_YEAR" 
                DataValueField="SOURCE_YEAR"  
                Font-Underline="False"
                 OnSelectedIndexChanged="ddlTo_Clicked" ValidationGroup="CompareValidator1"  >
            </asp:DropDownList>
            <br />
            <asp:CompareValidator ID="CompareValidator1" runat="server" ControlToCompare="ddlTo" 
            ControlToValidate="ddlyr"  Type="Integer" Operator= "LessThanEqual" ErrorMessage="**Year Must be Equal/Greater Than From Year**" Display="Dynamic">
            </asp:CompareValidator>        
         </td>
         </tr>
         <tr>  
         <td  colspan="2" align="left" valign="middle">
         <br /> <br/>
         STATE:
              <asp:DropDownList ID="ddlSt" runat="server" 
              DataSourceID="OdsState"
               DataTextField="STATE_COUNTRY_NAME" 
              DataValueField="STATE_COUNTRY_CODE"
               AutoPostBack="True"  OnInit="ddlst_Init"  
                 onselectedindexchanged="ddlSt_SelectedIndexChanged" AppendDataBoundItems="true">
                 <asp:ListItem Text="" Value="0"></asp:ListItem>
          </asp:DropDownList>
          <asp:ObjectDataSource ID="OdsState" runat="server" 
              OldValuesParameterFormatString="original_{0}" SelectMethod="GetData" 
              TypeName="stateTableAdapters.STATE_COUNTRYTableAdapter">
              <SelectParameters>
                  <asp:ControlParameter ControlID="ddlyr" Name="FromYear" 
                      PropertyName="SelectedValue" Type="Decimal" DefaultValue="null" />
                  <asp:ControlParameter ControlID="ddlTo" Name="ToYear" 
                      PropertyName="SelectedValue" Type="Decimal" />
                  <asp:ControlParameter ControlID="RBl1" Name="mytype" 
                      PropertyName="SelectedValue" Type="String" />
              </SelectParameters>
          </asp:ObjectDataSource>
                
             <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>   &nbsp; &nbsp;
           
             <asp:ObjectDataSource ID="SrcDistt" runat="server" 
                 OldValuesParameterFormatString="original_{0}" SelectMethod="GetData" 
                 TypeName="stateTableAdapters.DisttTableAdapter">
                 <SelectParameters>
                     <asp:ControlParameter ControlID="RBl1" DefaultValue="&quot;G&quot;" 
                         Name="mytype" PropertyName="SelectedValue" Type="String" />
                     <asp:ControlParameter ControlID="ddlSt"  Name="myState" 
                         PropertyName="SelectedValue" Type="String" />
                     <asp:ControlParameter ControlID="ddlyr" Name="FromYear" 
                         PropertyName="SelectedValue" Type="Decimal" />
                     <asp:ControlParameter ControlID="ddlTo" DefaultValue="&quot; &quot;" 
                         Name="ToYear" PropertyName="SelectedValue" Type="Decimal" />
                     <asp:ControlParameter ControlID="ddlCity" DefaultValue="null" Name="mycity" 
                         PropertyName="SelectedValue" Type="String" />
                 </SelectParameters>
             </asp:ObjectDataSource>  
          Cong.Dist: 
           <asp:DropDownList ID="ddlCongDistt" runat="server" Width="100" 
           AutoPostBack="true" OnInit="ddlCongDist_Init" 
               DataSourceID="SrcDistt" DataTextField="congrsnl_district_code"                  
                 onselectedindexchanged="ddlCongDistt_SelectedIndexChanged" >
                
                 </asp:DropDownList> <br /> <br/>
         </td>
         
         </tr>
         <tr>
         <td colspan="2" align="left" valign="middle">          
             <asp:Label ID="lblbud" runat="server" Text="**Budget Codes- Yr.2005 onwards**" ForeColor="Red"></asp:Label>
             <br />           
         BMM_CCR_ Code: 
          <asp:DropDownList ID="ddlBuccr" runat="server" AutoPostBack= "true" Width="100" 
                    DataSourceID="SrcBudCCR"  DataTextField="BMM_CCR_CODE"  
                    DataValueField="BMM_CCR_CODE">            
            </asp:DropDownList>
           
             <asp:ObjectDataSource ID="SrcBudCCR" runat="server" 
                 OldValuesParameterFormatString="original_{0}" SelectMethod="GetData" 
                 TypeName="stateTableAdapters.ccR_BudTableAdapter">
                 <SelectParameters>
                     <asp:ControlParameter ControlID="ddlyr" Name="FromYear" 
                         PropertyName="SelectedValue" Type="Decimal" />
                     <asp:ControlParameter ControlID="ddlTo" DefaultValue="&quot; &quot;" 
                         Name="ToYear" PropertyName="SelectedValue" Type="Decimal" />
                 </SelectParameters>
             </asp:ObjectDataSource>
             <asp:ObjectDataSource ID="SrcBmm" runat="server" 
                 OldValuesParameterFormatString="original_{0}" SelectMethod="GetData" 
                 TypeName="stateTableAdapters.Bud_codeTableAdapter">
                 <SelectParameters>
                     <asp:ControlParameter ControlID="ddlyr" Name="FromYear" 
                         PropertyName="SelectedValue" Type="Decimal" />
                     <asp:ControlParameter ControlID="ddlTo" DefaultValue="&quot; &quot;" 
                         Name="ToYear" PropertyName="SelectedValue" Type="Decimal" />
                     <asp:ControlParameter ControlID="ddlBuccr" DefaultValue="" Name="mybudCcr" 
                         PropertyName="SelectedValue" Type="String" />
                 </SelectParameters>
             </asp:ObjectDataSource> &nbsp; &nbsp;
             BMM_Code:
             <asp:DropDownList ID="ddlBmm" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlBmmCode_SelectedIndexChanged"
             DataSourceID="SrcBmm" DataTextField="BMM_CODE" DataValueField="BMM_CCR_CODE" >             
             </asp:DropDownList>
         </td>
         <td colspan="2" align="left" valign="middle">
             <asp:ObjectDataSource ID="SrcThrst" runat="server" 
                 OldValuesParameterFormatString="original_{0}" 
                 SelectMethod="GetData" 
                 TypeName="stateTableAdapters.HITS_THRUSTS_VWTableAdapter">
                 <SelectParameters>
                     <asp:ControlParameter ControlID="ddlyr" Name="FromYear" 
                         PropertyName="SelectedValue" Type="Decimal" />
                     <asp:ControlParameter ControlID="ddlTo" DefaultValue="&quot; &quot;" 
                         Name="ToYear" PropertyName="SelectedValue" Type="Decimal" />
                 </SelectParameters>
             </asp:ObjectDataSource>
         Thurst:
         <asp:DropDownList ID="ddlthrst"  AutoPostBack="true" runat="server" 
         DataSourceID="SrcThrst" DataTextField="THT_CODE" >
         </asp:DropDownList>&nbsp; &nbsp;
             <asp:ObjectDataSource ID="Srcdiv" runat="server" 
                 OldValuesParameterFormatString="original_{0}" SelectMethod="GetData" 
                 TypeName="stateTableAdapters.HITS_DIVISION_VWTableAdapter">
                 <SelectParameters>
                     <asp:ControlParameter ControlID="ddlyr" Name="FromYear" 
                         PropertyName="SelectedValue" Type="Decimal" />
                     <asp:ControlParameter ControlID="ddlTo" Name="ToYear" 
                         PropertyName="SelectedValue" Type="Decimal" />
                 </SelectParameters>
             </asp:ObjectDataSource>
         Division: 
         <asp:DropDownList ID="ddlDiv"
                          AutoPostBack="true" runat="server" 
                         DataSourceID="Srcdiv" DataTextField="DIVISION">
         </asp:DropDownList>
         
         <br /><br />
             <asp:ObjectDataSource ID="SrcAct" runat="server" 
                 OldValuesParameterFormatString="original_{0}" SelectMethod="GetData" 
                 TypeName="stateTableAdapters.HITS_ACTIVITY_CODES_VWTableAdapter">
                 <SelectParameters>
                     <asp:ControlParameter ControlID="ddlyr" Name="FromYear" 
                         PropertyName="SelectedValue" Type="Decimal" />
                     <asp:ControlParameter ControlID="ddlTo" DefaultValue="&quot; &quot;" 
                         Name="ToYear" PropertyName="SelectedValue" Type="Decimal" />
                 </SelectParameters>
                 </asp:ObjectDataSource>
         <asp:ObjectDataSource ID="SrcCAN" runat="server" 
                 OldValuesParameterFormatString="original_{0}" SelectMethod="GetData" 
                 TypeName="stateTableAdapters.HITS_CANS_VWTableAdapter">
             <SelectParameters>
                 <asp:ControlParameter ControlID="ddlyr" Name="FromYear" 
                     PropertyName="SelectedValue" Type="Decimal" />
                 <asp:ControlParameter ControlID="ddlTo" Name="ToYear"  
                     PropertyName="SelectedValue" Type="Decimal" />
             </SelectParameters>
             </asp:ObjectDataSource>             
        
         Activity Code:
         <asp:DropDownList  ID="ddlAct"  AutoPostBack="true" runat="server" 
         DataSourceID="SrcAct" DataTextField="ACTIVITY_CODE">
         
         </asp:DropDownList>  &nbsp; &nbsp;
         CAN: <asp:DropDownList ID="ddlCAN" AutoPostBack="true" runat="server" DataSourceID="SrcCAN"  DataTextField="CAN" >
         
         </asp:DropDownList>  
         </td>
         </tr> 
         <tr>
         <td  align="left" valign="middle">
             <asp:ObjectDataSource ID="SrcOrg" runat="server" 
                 OldValuesParameterFormatString="original_{0}" SelectMethod="GetData" 
                 TypeName="stateTableAdapters.HITS_ORGANIZATIONS_VWTableAdapter">
                 <SelectParameters>
                     <asp:ControlParameter ControlID="ddlyr" Name="FromYear" 
                         PropertyName="SelectedValue" Type="Decimal" />
                     <asp:ControlParameter ControlID="ddlTo" Name="ToYear" 
                         PropertyName="SelectedValue" Type="Decimal" />
                     <asp:ControlParameter ControlID="RBl1" Name="mytype" 
                         PropertyName="SelectedValue" Type="String" />
                 </SelectParameters>
             </asp:ObjectDataSource>
         
            Organization:
            <asp:DropDownList ID="ddlOrg" runat="server" DataSourceID="SrcOrg" AppendDataBoundItems="true"
             DataTextField="ORG_NAME" 
             AutoPostBack="True">
             <asp:ListItem Text="" Value="0"></asp:ListItem>      
            
            </asp:DropDownList> &nbsp; &nbsp; &nbsp;
            <%-- <asp:ObjectDataSource ID="SrcInvstg" runat="server" 
                 OldValuesParameterFormatString="original_{0}" SelectMethod="GetData" 
                 TypeName="stateTableAdapters.InvstgatorTableAdapter">
                 <SelectParameters>
                     <asp:ControlParameter ControlID="RBl1" DefaultValue="&quot;G&quot;" 
                         Name="mytype" PropertyName="SelectedValue" Type="String" />
                     <asp:ControlParameter ControlID="ddlyr" DefaultValue="" Name="FromYear" 
                         PropertyName="SelectedValue" Type="Decimal" />
                     <asp:ControlParameter ControlID="ddlTo" DefaultValue="&quot; &quot;" 
                         Name="ToYear" PropertyName="SelectedValue" Type="Decimal" />
                     <asp:ControlParameter ControlID="ddlSt" DefaultValue="" Name="myState" 
                         PropertyName="SelectedValue" Type="String" />
                 </SelectParameters>
             </asp:ObjectDataSource>
            Investigator: 
            <asp:DropDownList ID="ddlInvstg" runat="server" DataSourceID="SrcInvstg" 
            DataTextField="Investigator" 
                 DataValueField="STATE_COUNTRY_CODE" 
                 AutoPostBack="True">
            
            </asp:DropDownList>--%>
         </td>
         
         </tr> 
         <tr>
         <td align="left"> 
            <asp:Button ID="clear" OnClick="Clear_click" runat="server" Text="Clear"/>
            <asp:Button ID="Check" OnClick="Btn_check" runat="server" Text="check" />
           
           </td>
           </tr>          
         </table>  
         
         </hr>
            <asp:Label ID="Lbl1" runat="server" ForeColor="Blue"></asp:Label>   
        <asp:Label ID="lblmsg" runat='server' ForeColor="Red"></asp:Label> 
      
        <asp:Label ID="mesg" runat="server" Text="" ForeColor="Red"></asp:Label>
        <asp:Label ID="lblFm" runat="server" Text=""></asp:Label>
        <asp:Label ID="LblyTo" runat="server" Text=""></asp:Label>
        
        
                              

 </ContentTemplate>
 </asp:UpdatePanel>
 </div>
 
 

 
 
</asp:Content>

in c#

using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Collections.Specialized;
using AjaxControlToolkit;
using System.Configuration;
using System.Data.OracleClient;
using System.ComponentModel;



    public partial class Search : System.Web.UI.Page
    {
        string sSQL = " ";

        protected void Page_Prerender(Object sender, EventArgs e)
        {
            MakeDefault();
                 
        }
              

        protected void Page_Load(object sender, EventArgs e)
        {

           //if (IsPostBack &&ddlSt.SelectedIndex !=-1 )
               
           // {
           //     SrcCty.SelectParameters["myState"].DefaultValue = ddlSt.SelectedValue;

           // }  
            //MakeSQL();
        } 
        protected void Clear_click(object sender, EventArgs e)
        {
            Response.Redirect("~/search.aspx");
            
        }
               

        protected void RBl1_SelectedIndexChanged(object sender, EventArgs e)
        {
           
           
                MakeSQL(); 
           
        }

        public void MakeSQL()
        {

            sSQL += "AND RECORD_TYPE ='" + RBl1.SelectedValue.ToString() + "'";

            Lbl1.Text = sSQL;
        }

        public void MakeDefault()
        {
            SrcCty.SelectParameters["myState"].DefaultValue = null;
            SrcDistt.SelectParameters["myState"].DefaultValue = null;
            SrcDistt.SelectParameters["mycity"].DefaultValue = null;
        
        }
        protected void ddlyr_SelectedIndexChanged(object sender, EventArgs e)
        {
            Int16 fmyr = Convert.ToInt16(ddlyr.SelectedItem.Value);
            Int16 toyr = Convert.ToInt16(ddlTo.SelectedItem.Value);
            //if (fmyr > toyr)
            //{
            //    lblYrChk.Text = "**Check Years**";
            //}
            //else
            //    lblYrChk.Text = "";
                    
         
            sSQL += "AND SOURCE_YEAR ='" + ddlyr.SelectedItem.ToString() + "'";
            MakeSQL();


        }
        
        protected void ddlTo_Clicked(object sender, EventArgs e)
        {
            string sSQLfy = "";

            string toval = ddlTo.SelectedItem.ToString();
            string fmval = ddlyr.SelectedItem.ToString();
             
            if (ddlTo.SelectedIndex != -1)
            {
                //Int16 toyr = Convert.ToInt16(ddlTo.SelectedValue);
                Int16 fmyr = Convert.ToInt16(ddlyr.SelectedItem.Value);
                Int16 toyr = Convert.ToInt16(ddlTo.SelectedItem.Value);
                
                //if (toyr > fmyr)
                //{
                //    lblYrChk.Text = "**Check Years**";
                //}
                //else
                //    lblYrChk.Text = "";
                    
                sSQLfy = "AND SOURCE_YEAR between '" + toval + "' AND '" + fmval + "'";
                sSQL =sSQLfy.ToString();
                MakeSQL();

            }            
        }

        protected void ddlst_Init(object sender, EventArgs e)
        {
            ddlSt.Items.Insert(0, new ListItem("--", string.Empty));

        }

        protected void ddlSt_SelectedIndexChanged(object sender, EventArgs e)
        {
          
            
            sSQL += "AND STATE_COUNTRY_CODE='" + ddlSt.SelectedValue.ToString() + "'";
            MakeSQL();
        }

       
        protected void ddlcity_Init(object sender, EventArgs e)
        {
            
                       
            ddlCity.Items.Insert(0, new ListItem("---", string.Empty));

        }
        

        protected void ddlCity_SelectedIndexChanged(object sender, EventArgs e)
        {
           
            
            sSQL += "AND CITY='" + ddlCity.SelectedValue.ToString() + "'";
            lblmsg.Text = sSQL;
            MakeSQL();
        }
        protected void ddlCongDist_Init(object sender, EventArgs e)
        {


            ddlCongDistt.Items.Insert(0, new ListItem("---", string.Empty));

        }
        


        protected void ddlCongDistt_SelectedIndexChanged(object sender, EventArgs e)
        {
            sSQL += "AND  congrsnl_district_code ='" + ddlCongDistt.SelectedValue.ToString() + "'";
            MakeSQL();
        }

        protected void ddlBudCode_SelectedIndexChanged(object sender, EventArgs e)
        {

            sSQL += "AND BMM_CCR_CODE ='" + ddlBuccr.SelectedValue.ToString() + "'";
            MakeSQL();
        }
        protected void ddlBmmCode_SelectedIndexChanged(object sender, EventArgs e)
        {

            sSQL += "AND BMM_CODE ='" + ddlBmm.SelectedValue.ToString() + "'";
            MakeSQL();
        }

        protected void Btn_check(object sender, EventArgs e)
        {lblmsg.Text ="you have selected" +
                     ddlTo.SelectedValue.ToString() +"-->" +
                     ddlyr.SelectedValue.ToString() +"-->" +
                    ddlSt.SelectedValue.ToString() + "-->" +
                 ddlCity.SelectedValue.ToString()+ 
                 ddlBuccr.SelectedValue.ToString();
        }
}
0

my winzip is not working and I try to sent you thry attachment --doesn't work that way
Any other idea...

0

if your winzip is not working for some reason, download winrar. it is free, you can still attach. it is hard to trace that long code to locate error.

0

I downloaded rar form website but upload is giving me an error message upload fail
Pl. help

0

The file is notbig I simply included the code file i just post it but upload error is there

0

if you can give myour email I can sent you via email

0

Pls give like this. It will help you

protected void ddlCongDist_Init(object sender, EventArgs e)
        {
ddlCongDistt.Items.Clear();

            ddlCongDistt.Items.Insert(0, new ListItem("---", string.Empty));

        }
0

I tried items.clear()--
Now If i select State distt dropdown shows only distt within selected state.(As I am not using AppendDatabound in Distt)
Thsi works fine.
But in city dropdown I am using AppenDataBound (otherwise ALL Cities will not show in city dropdown) Is there any other way --cani develop some sort of function in c# to populate cities depending on state selection and distt for city selection??
Pl. help

0

you don't use AppendDatabound.
when the page is loading you can bind all the details in the ddlState.
when choose ddlState you can use onSelectedIndexChanged event

protected void ddlState_SelectedIndexChanged(object sender, EventArgs e)
{
   string ddlstateValue=ddlState.SelectedValue.toString();
   
}

after got ddlstateValue execute the query with this value and get ddlCity value and bind this data with ddlCity.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.