Hi

I have a asp.net web form in which I display registered customers in a Dropdown. In the Dropdown I can choose one customer,
and click a "Show data"-button. That should display all registered data about the chosen customer in Gridview.but i didn't
get the result.plz help me.my code is below

protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack )
        {
         Bind ();
        }
    }
    public void Bind()
    {

        OrdersBl obj = new OrdersBl();
        DataSet ds = new DataSet();

        ds = obj.GetorderDetails();


        DropDownList1.DataSource = ds.Tables[0];
        DropDownList1.DataTextField = "ShippingId";
        DropDownList1 .DataBind ();
    }
    protected void GridShow_click(object sender, EventArgs e)
    {
        datashow();

    }
    public void datashow()
    {
        OrdersBl obj = new OrdersBl();
        DataSet ds = new DataSet();


        ds = obj.onerecord();

        GridView1.DataSource = ds.Tables[0];
        GridView1.DataBind();
      
       
    }
    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        OrdersBl obj = new OrdersBl();
        DataSet ds = new DataSet();

        //string s;
        //s = DropDownList1.Text.ToString();
        ds = obj.onerecord();
        GridView1.DataSource = ds.Tables[0];
        GridView1.DataBind();
    }
}

ok if i undersstand you correctly , you want to show the users based on the selected user on the Dropdownlist, if so ,
1) You dont look like you filter your results
2) Does your Dropdownlist show data ? if so , you still need to set te DataValueField so that you can use that value to populate or Filter the grid Data
3) I see your commented come, it seemed like you wanted to retrieve the value of the selected dropdown, its not the correct attempt that you did, to get the value do something like

String MyVal = DropDownList1.SelectedValue;

this will be automatically casted to string, so you dont need the to string cast

Please be clear.

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.