Explanation:
I have an grid view which contains RepositoryItemCheckEdit column's and RepositoryItemTextEdit column's,grid view contains column's like Item Id
, Bar code
,Pack Id
etc
1)RepositoryItemCheckEdit
Same Item Id
and bar code
can come multiple items in grid view with different pack id
.
What I need is, if user selects any one item id's check box in grid view means i need all associated check box row's to be checked or unchecked viceversa. User may select either first check box or last check box then associated check box need to be checked or unchecked viceversa based upon user selection
2)RepositoryItemTextEdit
Same as like check box Column Edit,Text edit Column Edit need to be worked such as if user enters 100 in item id column cell value means then corresponding Item id row's should also be assigned as 100 as follows
void repchkCheckbox_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
{
DataTable dt_check = new DataTable();
dt_check = (DataTable)gcItemMaster.DataSource;
Int64 sItemId = Convert.ToInt64(gvItemMaster.GetRowCellValue(gvItemMaster.FocusedRowHandle, gvItemMaster.Columns["ItemID"]));
bool bDiscount = Convert.ToBoolean(e.Value);
int iItemcount = (from DataRow row in dt_check.Rows where (string)row["ItemID"] == "1" select row).Count();
int iRowHandle = gvItemMaster.FocusedRowHandle;
for (int i = 0; i < iItemcount; i++)
{
if (bDiscount)
gvItemMaster.SetRowCellValue(iRowHandle, gvItemMaster.Columns["AllowDiscount"], true);
else
gvItemMaster.SetRowCellValue(iRowHandle, gvItemMaster.Columns["AllowDiscount"], false);
iRowHandle++;
}
}
Illustrative Purpose : if i contains 5 rows in gridview with same itemid but different packid... if i check very first row checkbox of itemId means i can easily able to populate remaining checkbox like 2nd,3rd,4th,5th through increamenting rowhandle value But My Question is if suppose i check 3 row of gridview Itemid checkbox means i can able to populate only 4th and 5th row of checkbox state..but 1st and 2nd row remains the same...
I Found the Solution It's works Perfectly:
Int64 iItemId = Convert.ToInt64(gvItemMaster.GetRowCellValue(e.RowHandle, "ItemID"));
bool bDiscount = Convert.ToBoolean(e.Value);
for (int i = 0; i < gvItemMaster.DataRowCount; i++)
{
Int64 id = Convert.ToInt64(gvItemMaster.GetRowCellValue(i, "ItemID"));
if (id == iItemId)
{
if (bDiscount)
gvItemMaster.SetRowCellValue(i, gvItemMaster.Columns[""+sColumn.Replace(" ","")+""], true);
else
gvItemMaster.SetRowCellValue(i, gvItemMaster.Columns[""+sColumn.Replace(" ","")+""], false);
}
}