Link to home
Start Free TrialLog in
Avatar of Nobletucky2004
Nobletucky2004

asked on

Need to add to bound columns in a repeater control

How can I add a third bound column in a Repeater that takes the sum of the following two bound columns in a repeater control?
<%# DataBinder.Eval(Container.DataItem, "sched_m") %></td>
<%# DataBinder.Eval(Container.DataItem, "sched_f") %></td>

Avatar of AerosSaga
AerosSaga

I would use a datagrid instead, heres an example:

I would add a template column and make an itemdatabound subroutine to handle the OnItemDataBound event (put OnItemDataBound="DataGrid1_ItemDataBound" in the HTML source between the datagrid tags

Each time a row is added, it will call this subroutine and you can do math with each cell of the row(item)

    Protected Sub DataGrid1_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles DataGrid1.ItemDataBound
         'assuming template column will be column #7 and the dropdown list is column 5 and the quantity is column 6
         e.item.cells(7).text = CStr(CDbl(e.item.cells(6).text) * CDbl(CType(e.item.cells(5).controls(0) ,DropDownList).SelectedItem.Text)
    End Sub

Regards,

Aeros
ASKER CERTIFIED SOLUTION
Avatar of AerosSaga
AerosSaga

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 Nobletucky2004

ASKER

The report required too much formatting for a datagrid control so I'm stuck with the repeater.