Im working with a windows foem application. I have a dataset that was returned from a webservice. The third column ("Permanent") contains a bool. When i bind the data to a datagridview, that coulmn shows up as a series of checked checkboxes (since all the rows happened to have "true" for that value). What I want to do is modify the dataset, before binding it to the grid, to display the word "Permanent" if the bool is true and "Temporary" is the bool is false. Ive gotten the code the point where I recognise whether its true or false, but, because the column expects a bool, I cant put in the appropriate string. Any suggestions?
The error I get is: "String was not recognised as valid Boolean. Couldnt store "Permanent" in Permanent column. Expected type is Boolean."
It has been suggested that I use the RowDataBound event, but, sa far as I know, that only applies to ASP. That event doesnt seem to be available for DataGridViews in windows forms applications.
Code:
private void btnGetAccounts_Click(object sender, EventArgs e)
{
BindingSource bs = new BindingSource();
dsAccounts = new DataSet();
dsAccounts = myAccount.List(nSessionID, out nError, out sErrorMsg);
if (dsAccounts != null && dsAccounts.Tables.Count > 0)
{
//modify datadisplay
for (int i = 0; i < 10; i++)
{
if ((bool)dsAccounts.Tables[0].Rows[i][2] == true)
{
dsAccounts.Tables[0].Rows[i][2] = "Permanent";
}
}
bs.DataSource = dsAccounts;
bs.DataMember = dsAccounts.Tables[0].TableName;
dgvAccounts.DataSource = bs;
}
}
The error I get is: "String was not recognised as valid Boolean. Couldnt store "Permanent" in Permanent column. Expected type is Boolean."
It has been suggested that I use the RowDataBound event, but, sa far as I know, that only applies to ASP. That event doesnt seem to be available for DataGridViews in windows forms applications.