Hello, Ajith,
Thank you for writing back.
Here is demonstrated a sample approach how to store the initial cell values and restore them when you click the "
Reject" button:
public
RadForm1()
{
InitializeComponent();
DataTable dt =
new
DataTable();
dt.Columns.Add(
"Id"
,
typeof
(
int
));
dt.Columns.Add(
"Name"
,
typeof
(
string
));
for
(
int
i = 0; i < 10; i++)
{
dt.Rows.Add(i,
"Item"
+ i);
}
this
.radGridView1.DataSource = dt;
GridViewCommandColumn commandColumn =
new
GridViewCommandColumn(
"Reject"
);
commandColumn.UseDefaultText =
true
;
commandColumn.DefaultText =
"Reject"
;
radGridView1.MasterTemplate.Columns.Add(commandColumn);
this
.radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
this
.radGridView1.CellValidating += radGridView1_CellValidating;
this
.radGridView1.CommandCellClick += radGridView1_CommandCellClick;
}
private
void
radGridView1_CommandCellClick(
object
sender, GridViewCellEventArgs e)
{
foreach
(GridViewCellInfo cell
in
e.Row.Cells)
{
if
(cell.Tag!=
null
)
{
cell.Value = cell.Tag;
cell.Tag =
null
;
}
}
}
private
void
radGridView1_CellValidating(
object
sender, CellValidatingEventArgs e)
{
if
(e.ActiveEditor !=
null
&& e.Row.Cells[e.Column.Name].Tag ==
null
)
{
//store the initial value
e.Row.Cells[e.Column.Name].Tag = e.Row.Cells[e.Column.Name].Value;
}
}
The attached gif file illustrates the implemented behavior. Note that this is just a sample approach and it may not cover all possible cases. Feel free to modify it in a way which suits your requirement best.
I hope this information helps. If you have any additional questions, please let me know.
Regards,
Dess
Progress Telerik