Add More parameters on Select method

I need to
1) add a string "All" on top of my dropdown.
2) Add "MyState" parameter on Select Method of object Datasource.
3) On "ddlSt_SelectedIndexChanged" event I need to pass selected State Code to City drop down.
pl. help.

STATE:
              <asp:DropDownList ID="ddlSt" runat="server" 
              DataSourceID="OdsState"
               DataTextField="STATE_COUNTRY_NAME" 
              DataValueField="STATE_COUNTRY_CODE"
               AutoPostBack="True"   
                 onselectedindexchanged="ddlSt_SelectedIndexChanged" >
                
          </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" />
                  <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="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">
            </asp:DropDownList>   &nbsp; &nbsp;
           
             <asp:ObjectDataSource ID="SrcDistt" runat="server" 
                            OldValuesParameterFormatString="original_{0}"                                    
                        TypeName="stateTableAdapters.DisttTableAdapter">
                 <SelectParameters>
                     <asp:ControlParameter ControlID="RBl1" DefaultValue="&quot;G&quot;" 
                                            Name="mytype" PropertyName="SelectedValue" Type="String" />
                     <asp:ControlParameter ControlID="ddlyr"  Name="FromYear" 
                                         PropertyName="SelectedValue"
                                          Type="Decimal" 
                                         DefaultValue="" />
                     <asp:ControlParameter ControlID="ddlTo" 
                                            DefaultValue="&quot; &quot;" 
                                            Name="ToYear" 
                                            PropertyName="SelectedValue" 
                                            Type="Decimal" />
                 </SelectParameters>
             </asp:ObjectDataSource>

Recommended Answers

All 4 Replies

very simple....first you want to add "all" at the top...
dropdownlist has a property called appendDataboundItems -> by default it is false make it true....rest is binding the dropdown by objectdatasource...

hope it works out 4 u..

I used appendDatabound for some reason everytime I click it adds up enitre list of data.
can you pl. explain me how to bind object datasource --I am very new to c#.
Pl. help
Bless you

okey if you are new at C#....then remember one thing don't fear Raj is here...

http://www.asp.net/learn/data-access/

try this link...when i was just like you (newbie)....i learned alot from this tutorial...and trust me after reading this you'll be the big fan of "Scott Mitchell".

and here is basic tutorial which i've created for guys like you...

http://aspspider.info/dnanetwork/

this website not gonna open in the first hit...but try to refresh 2 or 3 times your web page then it works..

i've written some articals about gridview....hope it helps...enjoy..

Thanks Raj,
I need more guidance from you.
I have a radio button control, a "fromyear" dropdown control and a "TOyear" control. which populates years accoring to radio button selection.
I need to retrieve data for state cities and distt based on these three selection --by default ALL states, cities and distt should be in drop downs as soon as user change the selection in state cities should change respectively-- hw can i do that .
Can you give me step by step instructions to make it happen pl.
thanks

My page is really slow.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.