Click here to Skip to main content
16,023,124 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello ,
I have a CalendarExtender connected to a textbox. i need to catch the DateChange event in the server side so i can populate a DropDownList with items from my DB according to the selected date.
Posted

1 solution

Hi ,
Try this
C#
protected void TextBox2_TextChanged(object sender, EventArgs e)
    {
        SqlConnection con = new SqlConnection(@"Data Source=IT-DEV2\SQLEXPRESS;Initial Catalog=test;Integrated Security=True");
        string statment = string.Format("select item_code, Item_name, brand, size, section, price, Material, Qty, tax,tDate   from Items where tDate ='{0}'", TextBox2.Text);
        SqlDataAdapter da = new SqlDataAdapter(statment, con);
        DataSet ds = new DataSet();
        da.Fill(ds);
        DropDownList1.DataSource = ds.Tables[0];
        DropDownList1.DataTextField = "Item_name";
        DropDownList1.DataValueField = "item_code";
        DropDownList1.DataBind();
    }

ASP.NET
<div>
<asp:TextBox ID="TextBox2" runat="server" ontextchanged="TextBox2_TextChanged"></asp:TextBox>
<asp:CalendarExtender ID="TextBox2_CalendarExtender" runat="server"
    Enabled="True" TargetControlID="TextBox2">
</asp:CalendarExtender>
<asp:DropDownList ID="DropDownList1" runat="server">
</asp:DropDownList>
</div>

Best Regards
M.Mitwalli
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900