1

I want to populate dropdownlist according to Date

  <asp:DropDownList ID="ddlNewJobOrder" DataTextField="name" DataValueField="value"
                                                        runat="server" AppendDataBoundItems="True" DataSourceID="NewJobOrderDS" ToolTip="New Job Order List" Width="110" AutoPostBack="True" OnSelectedIndexChanged="ddlNewJobOrder_SelectedIndexChanged">
  <asp:SqlDataSource ID="NewJobOrderDS" runat="server" SelectCommand="SELECT Ref_No as name, Job_Order_ID as value FROM Job_Order WHERE Status <> 'JO_Completed' and Delivery_Date = @jaDate1 ORDER BY Ref_No" OnSelecting="NewJobOrderDS_Selecting">
 <SelectParameters>
 <asp:ControlParameter ControlID="JADate1" Name="jaDate1" PropertyName="Text" Type="DateTime"/>                                
 </SelectParameters>

so each time Date is changing,then the DDL should be re-populate again.

SqlDataSource1.SelectParameters.Remove(SqlDataSource1.SelectParameters["jaDate"]);
            SqlDataSource1.SelectParameters.Add("jaDate", JADate2.Text);

but the above code is not working, the DDL has no response after the 1st time I populate it.

2
  • how you bind JADate2? what is the value member and display member? try with PropertyName="SelectedValue" instead of PropertyName="Text" Commented Aug 12, 2013 at 4:06
  • @Damith JADate2 is a textbox. Commented Aug 12, 2013 at 5:28

1 Answer 1

1

There must be a postback the change the content of the dropdown and the textbox wont postback on its own. So you must add a button or use javascript to postback the form after someone entered text in the textbox.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.