Click here to Skip to main content
15,610,761 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i Have a textbox and CheckBoxList

If i enter orderid in TextBox(order id is the column name in my database) ,that time want to show the status of order id in CheckBox List

In the CheckBoxList i have four items


how to show clicked ,for example the orderid renovated or completed,validated,cancelled

Please give me a solution
Shahin Khorshidnia 27-May-12 12:59pm    
It depends on your application base (Win/ASP.Net/WPF ?) and your databse design. Are the type of the items (copleted, validated, cancelled) are Bit? If yes, then you can Select them after TextChanged as a Collection (List) and rebind them to CheckBoxList. Firstly, plase reTag your question and specify WinForm or ASP.NET or .... .

1 solution

if you have 2table , first for orders and second for status, and each order have a status_id, this is the solution:

this should be your markup:
<asp:TextBox ID="TextBox1" runat="server" ontextchanged="TextChanged"></asp:TextBox>
    <asp:Repeater ID="rptstatus" runat="server" DataSourceID="SqlDataSource1">
            <asp:CheckBox ID="CheckBox1" 
            Checked='<%#(int)Eval("status_id")==(int)Session["id"] %>' 
            Text='<%#Eval("status") %>' runat="server" Enabled="False" />
        <asp:SqlDataSource ID="SqlDataSource1" runat="server"
            ConnectionString="<%$ ConnectionStrings:testConnectionString %>"
            SelectCommand="SELECT * FROM [status]"></asp:SqlDataSource>

and this is for code behind:
protected void Page_Load(object sender, EventArgs e)
    //set session to 0 for first page load and empty text box
    if (!Page.IsPostBack)
        Session["id"] = 0;

protected void TextChanged(object sender, EventArgs e)
    int id = Convert.ToInt32(TextBox1.Text);
    using (var context = new testEntities())
        var status_id = (from a in context.orders where a.order_id == id select a).FirstOrDefault();
        Session["id"] = status_id.status_id;
//here you get the status id and set it to session


comment if you have a question!
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