protected void ddlLocation_SelectedIndexChanged(object sender, EventArgs e) { try { DropDownList ddl = sender as DropDownList; TableCell tc = ddl.Parent as TableCell; GridViewRow gvr = tc.Parent as GridViewRow; string strItemCode = gvr.Cells[1].Text; string strLocationQty = string.Empty; DropDownList ddlLocation = (DropDownList)gvr.FindControl("ddlLocation"); Get_locationWisePartData(strItemCode, ddl.SelectedValue.ToString(), ref strLocationQty); gvr.Cells[7].Text = strLocationQty; //Get Avg Cost DataSet dsAvgCost = new DataSet(); decimal DAvgCost = 0; dsAvgCost = SysFunc.ItemAvgCost(strItemCode, Session["DealerCode"].ToString()); Label lblAvgCost = (Label)gvr.FindControl("lblAvgCost"); if (dsAvgCost.Tables[0].Rows.Count != 0) { DAvgCost = Convert.ToDecimal(dsAvgCost.Tables[0].Rows[0]["Cost"]); lblAvgCost.Text = DAvgCost.ToString(); } } catch (Exception ex) { SysFunc.UserMsg(LbErr, Color.Red, ex.Message); } }