dropdownlist select value

2 posts, 0 answers
  1. Arun
    Arun avatar
    13 posts
    Member since:
    May 2013

    Posted 03 Jul 2013 Link to this post

     Hi,
           I am using rad dropdownlist in my project.In My project i show full details in gridview from database on pageload.After that i show the database values in grid view depending upon the selected values in dropdownlist till it works properly.But once i select the dropdown value it shows only the database values in grid view depending upon the selected values.I need to show the full details full details in gridview from database by selecting (select) value in dropdownlist. I want to know how to insert (select) as default value in dropdownlist.
    I tried with 'default message' but it doesn't works.Please give me the solution.

    Thanks,
     Arun.

  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 03 Jul 2013 Link to this post

    Hi Arun,

    Please have a look into the following code I tried which works fine at my end.

    ASPX:
    <asp:Label ID="Label1" runat="server" Text="Select Customers from "></asp:Label>
    <telerik:RadDropDownList ID="RadDropDownList1" runat="server" AutoPostBack="true"
        OnSelectedIndexChanged="RadDropDownList1_SelectedIndexChanged">
        <Items>
            <telerik:DropDownListItem runat="server" Text="Select" Value="-1" Selected="true" />
            <telerik:DropDownListItem runat="server" Text="France" Value="0" />
            <telerik:DropDownListItem runat="server" Text="Brazil" Value="1" />
            <telerik:DropDownListItem runat="server" Text="USA" Value="2" />
        </Items>
    </telerik:RadDropDownList>
    <br />
    <br />
    <telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="true" DataSourceID="SqlDataSource1">
    </telerik:RadGrid>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
        SelectCommand="select CustomerID, CompanyName, City, Country from [Customers];">
    </asp:SqlDataSource>

    C#:
    protected void populateGrid(string countryName)
    {
        if (countryName.Equals("Select"))
        {
            SqlDataSource1.SelectCommand = "select CustomerID, CompanyName, City, Country from [Customers];";
            RadGrid1.Rebind();
        }
        else
        {
            SqlDataSource1.SelectCommand = "select CustomerID, CompanyName, City, Country from [Customers] where Country='" + countryName + "';";
            RadGrid1.Rebind();
        }
    }
    protected void RadDropDownList1_SelectedIndexChanged(object sender, Telerik.Web.UI.DropDownListEventArgs e)
    {
        string selectedItem = RadDropDownList1.SelectedText;
        populateGrid(selectedItem);
    }

    Thanks,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top