dcass
asked on
Assign cssClass after data.Rows.Add(row)
How do you assign the property of a column of a row when you add the row?
Here is the code that works but displays this row a different size and font:
DataTable data = dbAccess.getDataTable(con, table, sqlSv);
DataRow rowx;
rowx = data.NewRow();
dContent = Convert.ToDecimal(PriceTot );
sContent = dContent.ToString("###,### ,###,###.# 0");
rowx["Sub Total"]=sContent.ToString( );
data.Rows.Add(rowx);
dg.DataSource = data;
However, cssClass is not a property of data, data.Rows, data.Columns, etc.
Then I assign the other rows the cssClass:
protected void OnItemDataBoundEventHandle r(Object sender, DataGridItemEventArgs e)
{
int iCtr = e.Item.Controls.Count;
for (int i=0; i<iCtr; i++)
{
TableCell tcn = (TableCell) e.Item.Controls[i];
tcn.CssClass = "clsListRecordHeader";
}
}
BUT THIS DOESN'T PICK UP THE ADDED ROW -
Please HELP!
Here is the code that works but displays this row a different size and font:
DataTable data = dbAccess.getDataTable(con,
DataRow rowx;
rowx = data.NewRow();
dContent = Convert.ToDecimal(PriceTot
sContent = dContent.ToString("###,###
rowx["Sub Total"]=sContent.ToString(
data.Rows.Add(rowx);
dg.DataSource = data;
However, cssClass is not a property of data, data.Rows, data.Columns, etc.
Then I assign the other rows the cssClass:
protected void OnItemDataBoundEventHandle
{
int iCtr = e.Item.Controls.Count;
for (int i=0; i<iCtr; i++)
{
TableCell tcn = (TableCell) e.Item.Controls[i];
tcn.CssClass = "clsListRecordHeader";
}
}
BUT THIS DOESN'T PICK UP THE ADDED ROW -
Please HELP!
ASKER
It's there - I just didn't copy it in.
The problem is that the OnItemDataBoundEventHandle r event doesn't seem to get that row I added.
Yes, any examples are appreciated.
The problem is that the OnItemDataBoundEventHandle
Yes, any examples are appreciated.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I don't see any difference between your code and mine.
Can you see anything different that you are doing to pick up the added row?
It still doesn't work on mine.
Can you see anything different that you are doing to pick up the added row?
It still doesn't work on mine.
ASKER
I figured it out - will give you the points for responding.
Let me know what is the problem you had and How did you fix it?
ASKER
There was nothing in the first column because it was just a "totals" column and it was trying to assign a hyperlink - I should have put all the code.
The code above actually worked, I just had more in there than I copied in.
The code above actually worked, I just had more in there than I copied in.
This statemnet should be after adding the row to the DataTable.
I worked on one example. It is working fine . If you want I can send that Example