Welcome Guest Search | Active Topics | Sign In | Register

DataGrid - OnRowDataBound Options
mrdata
Posted: Monday, March 22, 2010 4:03:02 AM
Rank: Newbie
Groups: Member

Joined: 2/7/2009
Posts: 2
Hello,

Is there a similar event (OnRowDataBound) with the EO datagrid? I usually use that event to control information in the datagrid, ex:

protected virtual void gvMainShare_OnRowDataBound(Object sender, GridViewRowEventArgs e)
{

Label _lbl;
double _buffer;

if (e.Row.RowType == DataControlRowType.DataRow)
{
_lbl = (Label)e.Row.FindControl("lblGain");
_buffer = ConvertAmount(_lbl.Text);

if (_buffer > 0)
e.Row.ForeColor = System.Drawing.Color.Green;

if (_buffer < 0)
e.Row.ForeColor = System.Drawing.Color.Red;

e.Row.Attributes.Add("onmouseover", "this.className='hightlighrow'");
e.Row.Attributes.Add("onmouseout", "this.className='normalrow'");


}

}

If not how can I for instance hide or change information in a label or button during databind?

Thanks in advance
eo_support
Posted: Monday, March 22, 2010 8:55:19 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

You do not need to do mouseover or mouseout on the grid item with our Grid. That has already been taken care of. You would just specify two different "item styles", one for regular items and one for hovering items. See here for more details:

http://doc.essentialobjects.com/library/1/grid/styling.aspx

There is no direct equivalent of OnRowDataBound on EO.Grid, but there are several ways to display cell contents in different format:

1. For each column you can set DataField and StyleField. DataField is the field where your data come from, StyleField is the field (optional) that provides a CSS class name to the cell. This allows you to have any style on any cell based on your data source. See here for more details:

http://doc.essentialobjects.com/library/1/eo.web.gridcolumn.stylefield.aspx

2. You can also set the column's DataFormat property. If set, the grid will use DataFormat to format the cell value, then display the result HTML in the cell. For example, if your DB value is an image Url and the format is "<img src='{0}' />", then the Grid will display the actual image in the cell;

3. You can also set StyleSetID field on the Grid. The idea for this field is the same as GridColumn.StyleField. However this field is set on the Grid thus works on row level instead of cell level.

http://doc.essentialobjects.com/library/1/eo.web.grid.stylesetidfield.aspx

Hope this helps. Please let us know if you have any more questions.

Thanks!
mrdata
Posted: Monday, March 22, 2010 9:43:08 AM
Rank: Newbie
Groups: Member

Joined: 2/7/2009
Posts: 2
Thanks,

It's not just style, it's also data manipulation. For instance if column X contains certain information for a row, I might want to "hide" the information in column Y

Thanks again for the quick response
eo_support
Posted: Monday, March 22, 2010 11:39:09 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

Style can achieve anything possible with CSS so it’s rather flexible. For example, to hide a piece of information, you just use "display:none" in your CSS rule. There is also a very interesting way of using parent child rules if you only want to apply the style to certain elements:

http://www.essentialobjects.com/forum/postst3177_Grid-checkbox-column-I-need-to-disable-checkbox-on-one-cell.aspx

You can also load your data into a DataTable and then pre-format it in the DataTable instead of formatting it in OnRowDataBound, or pre-fill a style field based on your logic. The reason that EO.Grid does not let you to do the same kind of format as OnRowDataBound is because EO.Grid can handle large amount of data and often does format on client side. For example, if you have 500 rows, with ASP.NET GridView the HTML for all 500 rows are generated on the server side and send to the client all together. With EO.Grid only the data is sent to the client side. The Grid will dynamically re-format the HTML based on your current page, sorting, column orders, etc without going back to the server. By perform all these tasks such as editing, paging and sorting on the client side it is able to give user a superior user experience.

Thanks


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.