Link to home
Start Free TrialLog in
Avatar of dcass
dcassFlag for United States of America

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 OnItemDataBoundEventHandler(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!
Avatar of w_shaila
w_shaila

Where is your dg.DataBind() Statement? . Please check where you have written this Statement ?
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
Avatar of dcass

ASKER

It's there - I just didn't copy it in.
The problem is that the OnItemDataBoundEventHandler event doesn't seem to get that row I added.
Yes, any examples are appreciated.
ASKER CERTIFIED SOLUTION
Avatar of w_shaila
w_shaila

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dcass

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.
Avatar of dcass

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?
Avatar of dcass

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.