I tried adding the radio button to the data source as I have no idea how to add the radio button to a dynamic Obout grid and I'm receiving a Collection was modified; enumeration operation might not execute
exception. is there a way to add it to the DataTable a different way? or should I try adding the radio button to a list and then adding the list instead of the radio button directly?
public Grid gridTickets = new Grid(); //Obout grid initializing code
Column id = new Column();//Creating the Obout grid columns
id.DataField = "id";
id.HeaderText = "Ticket Nr";
id.Width = globals.SecurityKey == 5 ? "10%" : "8%";
Column severity = new Column();
severity.DataField = "severity";
severity.HeaderText = "Severity";
severity.Width = "10%";
gridTickets.Columns.Add(id);//Adding the columns to the Obout grid
gridTickets.Columns.Add(severity);
placeHere.Controls.Add(gridTickets);//Add the OboutGrid to the Place holder on the aspx side
dt = helpers.DisplayTickets();
RadioButton rb = new RadioButton();
int i = 1;
foreach (DataRow r in dt.Rows)
{
string temp = r[1].ToString();
if (r[].ToString().Contains("Level"))
{
rb.ID = "rb" + i;
dt.Rows.Add(r[1].ToString() + rb);
}
i++;
}
gridTickets.DataSource = dt;//Adding the DataTable to the Obout grid DataSource
gridTickets.DataBind();
Hi guys thank you all for the awesome responses they helped me a lot I ended up using a Font awesome icon and adding that as a Lable
in DataBound
method. And even made it only show when an entry's resolution date has already expired.
This Is the building of the grid
public Grid gridTickets = new Grid(); //Obout grid initializing code
Column id = new Column();//Creating the Obout grid columns
id.DataField = "id";
id.HeaderText = "Ticket Nr";
id.Width = globals.SecurityKey == 5 ? "10%" : "8%";
Column severity = new Column();
severity.DataField = "severity";
severity.HeaderText = "Severity";
severity.Width = "10%";
gridTickets.ID = "gridTickets";//Grid settings
gridTickets.RowDataBound += new GridRowEventHandler(OnGridDataBound);// adding a DataBound method
gridTickets.Columns.Add(id);//Adding the columns to the Obout grid
gridTickets.Columns.Add(severity);
placeHere.Controls.Add(gridTickets);//Add the OboutGrid to the Place holder on the aspx side
DataTable dt = helpers.DisplayTickets();
gridTickets.DataSource = dt;//Adding the DataTable to the Obout grid DataSource
gridTickets.DataBind();
And this is the method
protected void OnGridDataBound(object sender, GridRowEventArgs e)
{
Label lb = new Label();
lb.Attributes.Add("class", "fa fa-circle");
lb.Attributes.Add("style", "color:red; float:right; margin-top:-17px; margin-right:10px;");
for (int i = 0; i < e.Row.Cells.Count; i++)
{
DateTime checkdate = Convert.ToDateTime(e.Row.Cells[7].Text);
DateTime checkdateL1 = checkdate.AddHours(6);
DateTime checkdateL2 = checkdate.AddHours(12);
DateTime checkdateL3 = checkdate.AddHours(48);
if (e.Row.Cells[i].Text == "Level 1" && DateTime.Now >= checkdateL1)
{
e.Row.Cells[2].Controls.Add(lb);
}
if (e.Row.Cells[i].Text == "Level 2" && DateTime.Now >= checkdateL2)
{
e.Row.Cells[2].Controls.Add(lb);
}
if (e.Row.Cells[i].Text == "Level 3" && DateTime.Now >= checkdateL3)
{
e.Row.Cells[2].Controls.Add(lb);
}
}
}