When the page is first opened, the data I want is taken in the form of a list on the controller side in the table I show. While I show the data in the column, I want to show the values that I entered myself. For example, the page has 6 column values. The values of one column come as boolean. Naturally, it writes the values as "True" or "False" to the table. I want it to read "Open" if the value is "True" and "Close" if it is "False". How can I do it?
my .aspx code:
<telerik:GridBoundColumn DataField="PublishOnB2B" HeaderText="Is the product Web On/Off?"
FilterControlWidth="100px" AutoPostBackOnFilter="true" CurrentFilterFunction="Contains" AllowFiltering="false"
FilterDelay="1500" ShowFilterIcon="false">
</telerik:GridBoundColumn>
my .aspx.cs code:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
products = new LogicRules.B2B.BL_Product().GetAllProductsForSAPUpdate().OrderBy(x => x.ItemName).ToList();
Session["products"] = products;
RadGrid1.DataSource = products;
RadGrid1.DataBind();
}
}
Here one column holds bool value. When printing values in the column it naturally writes as "True" or "False". I want it to write "Open" if "True" and "Close" if "False". I could not do it. How can I do that?
CodePudding user response:
since you want to change the data inside, you will have to loop through all records returned in the DataTable
foreach(DataRow row in dataTable.Rows) //products.Rows
{
if((bool) row["columnName"])
{
row["columnName"] = "open";
continue;
}
row["columnName"] = "close";
}
p.s. this is not a good practice for large data