protected void Grid1_OnRowDataBound(object sender, Obout.Grid.GridRowEventArgs e) { iPartRequestClient objService = new iPartRequestClient(); CustomProfile profile = CustomProfile.GetProfile(); try { if (e.Row.RowType == Obout.Grid.GridRowType.DataRow) { //Obout.Grid.GridDataControlFieldCell cell = e.Row.Cells[6] as Obout.Grid.GridDataControlFieldCell; //Obout.Grid.GridDataControlFieldCell cell = e.Row.Cells[7] as Obout.Grid.GridDataControlFieldCell; Obout.Grid.GridDataControlFieldCell cell = e.Row.Cells[8] as Obout.Grid.GridDataControlFieldCell; DropDownList ddl = cell.FindControl("ddlUOM") as DropDownList; HiddenField hdnUOM = cell.FindControl("hdnMyUOM") as HiddenField; //Label rowQtySpn = e.Row.Cells[9].FindControl("rowQtyTotal") as Label; Label rowQtySpn = e.Row.Cells[10].FindControl("rowQtyTotal") as Label; //TextBox txtUsrQty = e.Row.Cells[6].FindControl("txtUsrQty") as TextBox; TextBox txtUsrQty = e.Row.Cells[7].FindControl("txtUsrQty") as TextBox; int ProdID = Convert.ToInt32(e.Row.Cells[0].Text); decimal moq = Convert.ToDecimal(e.Row.Cells[6].Text); TextBox txtUsrPrice = e.Row.Cells[11].FindControl("txtUsrPrice") as TextBox; Label rowPriceTotal = e.Row.Cells[12].FindControl("rowPriceTotal") as Label; DataSet dsUOM = new DataSet(); dsUOM = objService.GetUOMofSelectedProduct(ProdID, profile.DBConnection._constr); ddl.DataSource = dsUOM; ddl.DataTextField = "Description"; ddl.DataValueField = "UMOGroup"; ddl.DataBind(); decimal SelectedQty = 0, SelectedUOM = 0; decimal Price = decimal.Parse(txtUsrPrice.Text.ToString()); //ddl.SelectedValue = e.Row.Cells[6].Text; if (hdnTemplateID.Value != "") { long TemplID = Convert.ToInt64(hdnTemplateID.Value); string selectedUom = objService.GetSelectedUomTemplate(TemplID, ProdID, profile.DBConnection._constr); ddl.SelectedIndex = ddl.Items.IndexOf(ddl.Items.FindByValue(selectedUom.ToString())); rowQtySpn.Text = txtUsrQty.Text; rowPriceTotal.Text = e.Row.Cells[12].Text; } else { ddl.SelectedIndex = 2; SelectedQty = decimal.Parse(dsUOM.Tables[0].Rows[2]["Quantity"].ToString()); SelectedUOM = decimal.Parse(dsUOM.Tables[0].Rows[2]["UOMID"].ToString()); decimal rowQty = decimal.Parse(txtUsrQty.Text.ToString()); decimal UsrQty = SelectedQty * rowQty; hdnSelectedQty.Value = SelectedQty.ToString(); rowQtySpn.Text = UsrQty.ToString(); } ddl.Attributes.Add("onchange", "javascript:GetIndex(this,'" + hdnUOM.ClientID.ToString() + "','" + rowQtySpn.ClientID.ToString() + "','" + txtUsrQty.ClientID.ToString() + "'," + e.Row.RowIndex + "," + Price + ",'" + rowPriceTotal.ClientID.ToString() + "'," + moq + ")"); txtUsrQty.Attributes.Add("onblur", "javascript:GetIndexQty(this," + SelectedQty + "," + SelectedUOM + ",'" + rowQtySpn.ClientID.ToString() + "','" + txtUsrQty.ClientID.ToString() + "'," + e.Row.RowIndex + "," + Price + ",'" + rowPriceTotal.ClientID.ToString() + "'," + moq + ")"); txtUsrPrice.Attributes.Add("onblur", "javascript:GetChangedPrice(this," + SelectedQty + "," + SelectedUOM + ",'" + rowQtySpn.ClientID.ToString() + "','" + txtUsrQty.ClientID.ToString() + "'," + e.Row.RowIndex + ",'" + rowPriceTotal.ClientID.ToString() + "'," + ProdID + ")"); //} } } catch (System.Exception ex) { Login.Profile.ErrorHandling(ex, this, "Request Template", "Grid1_OnRowDataBound"); } finally { objService.Close(); } }