asp.net - Gridview binding details -


I've got a combobox that I bind to a database and when I order from the combo box, order details And customer details on different gridview I have achieved that, now I have to be the "all" option in that combo box, when everyone is selected, it displays all the order details and customer details of the database.

Note that I have found the table which is the foreign key for the ordersDetails and customerDetails order table I have a foreign key I now retrieve data using the option but now the option does not have a foreign key that is facing the problem. I have compiled my Gridview with a data source.

My code for selected cabobox binding

  SELECT [ID], [orderName],   

by order of my gridview code Select which items display the selected items on the gridview,

  select customer name, customer name, details on the order order order in order to order from the combobox. ID = order details Orderer where ID = @ .orderRef    

to select all the details and all order details For the database you will need to change your query

Protected Zero GetOrders (int OrderID = 0) on your DropDownList.SelectedIndexChanged

  / Connection objects are defined here // get the order details if (order id == 0) {string sql = "SELECT * FROM OrderDetails"; } Other {string sql = "select * order defratch where order id =" + order id; } Dataset DS = Null; SqlDataAdapter da = New Default (SqlDataAdapter); // Check it, this can be a SqlTableAdapter da.SelectCommand = New SqlCommand (System.Data.sql, conn); Da.Fill (DS); GvOrderDetails.DataSource = DS; GvOrderDetails.DataBind (); }   

It just gets data from one of your gridview (in a dataset so that you can gridview the page).

You can copy this process

The above code assumes that you have 0 set values ​​in all your items in the dropdownlight.

So if your DropDownList is called ddlOrders, then the call process is as follows:

  Secure void ddl orderers selected items (Object Sender, System.EventArgs e } {GetOrders (ddlOrders.SelectedItem.Value); }   

The same with GetCustomers.

These will populate the gridview with rows that match a specific order id or all orders.

Hope it helps

Comments