Hi, I've a web page that contains a Customers DDL, and a ClassCode gridview with a Salesman DDL. So far i have manged to populate the Customers DDL as well as binding data to the ClassCode gridview/ Salesman DDL. My next step is depending on which customer is selected(code event below), query the DB to get all relevant ClassCodes/Salesmen and update the gridview and any instances where the classcode doesn't exist for the customer the Salesman DDL will have a default value. Here's my code so far:
can anyone help me to get the ClassCode for that row by getting DataKeys of the GridView, using the RowIndex of the Row. See if you have a SalesMan for the ClassCode.Code:protected void ddlCustomers_SelectedIndexChanged(object sender, EventArgs e) { BindData(); DataTable dt = new DataTable(); try { con = new SqlConnection(strConnString); SqlDataAdapter ad = new SqlDataAdapter("exec dbo.GetProductClsCodeAndSalesman '" + ddlCustomers.SelectedItem.Text + "'", con); DataSet ds = new DataSet(); ad.Fill(ds, "ProductClsCodeAndSalesman"); for (int i = 0; i < gvProductClass.Rows.Count; i++) { //the logic to check each row and update the Salesman goes here } }...
If you do, use FindControl to find the DropDownList in the Row, and set its SelectedValue.




Reply With Quote