protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { Label lblPrice = (Label)e.Row.FindControl("lblPrice"); Label lblUnitsInStock = (Label)e.Row.FindControl("lblUnitsInStock"); decimal price = Decimal.Parse(lblPrice.Text); decimal stock = Decimal.Parse(lblUnitsInStock.Text); totalPrice += price; totalStock += stock; totalItems += 1; } if (e.Row.RowType == DataControlRowType.Footer) { Label lblTotalPrice = (Label)e.Row.FindControl("lblTotalPrice"); Label lblTotalUnitsInStock = (Label)e.Row.FindControl("lblTotalUnitsInStock"); lblTotalPrice.Text = totalPrice.ToString(); lblTotalUnitsInStock.Text = totalStock.ToString(); lblAveragePrice.Text = (totalPrice / totalItems).ToString("F"); } }
Best Regard's Prabhakar
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName.Equals("Update")) { int state = 0; int index = int.Parse(e.CommandArgument.ToString()); GridViewRow row = GridView1.Rows[index]; DropDownList lstState = (DropDownList)row.FindControl("StateID"); state = int.Parse(lstState.SelectedValue.ToString()); ObjectDataSource1.UpdateParameters.Add("StateID", state.ToString()); } }
void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { Control ctrl = e.CommandSource as Control; if (ctrl != null) { GridViewRow _currenrtrow = ctrl.Parent.NamingContainer as GridViewRow; //Now you can find control on the row where event is raised by using FindControl method. //Control findme=_currenrtrow.FindControl("ControlID to Find in that row"); } }
Regards, Susan
Login to post response