protected void AddNewExpressions(object sender, EventArgs e) { bool FilterNot = ((CheckBox)GridViewExpressions.FooterRow.FindControl("CheckBoxNot")).Checked; bool LeftParen = ((CheckBox)GridViewExpressions.FooterRow.FindControl("CheckBoxLeftParen")).Checked; string FilterField = ((DropDownList)GridViewExpressions.FooterRow.FindControl("ddlField")).SelectedItem.Text; string FilterOperatorIdStr = ((DropDownList)GridViewExpressions.FooterRow.FindControl("ddlOperatorDesc")).SelectedItem.Value; int FilterOperatorId = Int32.Parse(FilterOperatorIdStr); string OperatorDesc = ((DropDownList)GridViewExpressions.FooterRow.FindControl("ddlOperatorDesc")).SelectedItem.Text; string FilterValue = ((ComboBox)GridViewExpressions.FooterRow.FindControl("comboBoxValue")).SelectedItem.Text.Trim(); bool RightParen = ((CheckBox)GridViewExpressions.FooterRow.FindControl("CheckBoxRightParen")).Checked; string ConjunctionIdStr = ((DropDownList)GridViewExpressions.FooterRow.FindControl("ddlConjunctionExp")).SelectedItem.Value; int ConjunctionId = Int32.Parse(ConjunctionIdStr); string ConjunctionExp = ((DropDownList)GridViewExpressions.FooterRow.FindControl("ddlConjunctionExp")).SelectedItem.Text; DataType DataTypeOfFilterField = filterBuilderRepo.FindFilterDefinedFields(int.Parse(cboProductId.SelectedValue.ToString()), chkBoxHistory.Checked, int.Parse(cboSOR.SelectedValue.ToString())) .Where(x => x.ColumnName == FilterField) .Select(y => y.FieldDataType) .SingleOrDefault();
// format value - add '' if needed
FilterValue = FormatValue(FilterField, OperatorDesc, FilterValue);
// add new row in dtForExpressionsGridView
DataRow newRow = dtForExpressionsGridView.NewRow();
newRow["FilterExpressionId"] = Guid.NewGuid();
newRow["FilterNot"] = FilterNot;
newRow["LeftParen"] = LeftParen;
newRow["FilterField"] = FilterField;
newRow["FilterOperatorId"] = FilterOperatorId;
newRow["OperatorDesc"] = OperatorDesc;
newRow["FilterValue"] = FilterValue;
newRow["RightParen"] = RightParen;
newRow["ConjunctionId"] = ConjunctionId;
newRow["ConjunctionExp"] = ConjunctionExp;
int row = Convert.ToInt32(GridViewExpressions.EditIndex);
dtForExpressionsGridView.Rows.Add(row);
I am trying to add row between two rows or i want to add the row randomly between Two roaws which have the same data field .