How can I set a value into gridview column? The thing is the column was added manually, not from the database. What I want is when the checklist value was 1
the cek22
column got ticked
and when value was 0
the cek22
column was unticked
. I used devexpress.
Example of my code that I used:
public void abc()
{
//select query in here
gridControl1.DataSource = dt;
//iam adding a column here
dt.Columns.Add("cek22",typeof(bool));
}
If your column is added manually then your column is working in unbound mode. So, you can just use its unbound expression. If you want to update your checklist
column from cel22
then you can use CellValueChanging
event.
Here is example:
var table = new DataTable();
table.Columns.AddRange(new[]
{
new DataColumn("preferred", typeof(string)),
new DataColumn("checklist", typeof(int))
});
table.Rows.Add("Director Fury", 1);
table.Rows.Add("Maria Hill", 0);
gridControl1.DataSource = table;
gridView1.PopulateColumns();
var column = new GridColumn();
column.FieldName = "cek22";
column.UnboundType = UnboundColumnType.Boolean;
column.UnboundExpression = "[checklist]";
column.Visible = true;
gridView1.Columns.Add(column);
gridView1.CellValueChanging += (sender, e) =>
{
if (e.Column.FieldName == "cek22")
gridView1.SetRowCellValue(e.RowHandle, "checklist", e.Value);
};
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments