how to process data binded to datagrid?
Datagrids are great but there seems to be a lack of manipulating data that is binded to the columns. Say I want to set the selectedindex of a dynamically populated dropdownlist in a datagrid:
*this is populating the dropdownlist with day from 1 - 31.
<EditItemTemplate>
<asp:DropDownList id="edit_finishdate_day" DataSource="<%# PopulateDay() %>" DataTextField="dayvalue" DataValueField="dayvalue" SelectedIndex='<%# DataBinder.Eval(Container.DataItem, "finishdate") %>' runat="Server"></asp:DropDownList>
</EditItemTemplate>
This won't work obviously because it pulls out the full date of 24/11/2004, when what I want is just the day: 24.
So how can I process the Container.DataItem or perform an expression on it to find just the day.
The setting of the selectedindex in the dropdownlist is just an example. Say I was pulling out the document size which is stored in the database as bytes eg. 55655
<ItemTemplate>
<%# DataBinder.Eval(Container.DataItem, "documentsize") %>
</ItemTemplate>
and I wanted to display the size in Kb, or Mb.
Would appreciate any help.
Cheers.
|