function call from boundcolumn

T

tshad

Is there a way to call a function from a boundcolumn tag?

I have some icons that I set as visible or not depending on values set in my
table.

I have a Datagrid that I am binding to and after binding I then go through
the DataGrid item by item checking the values and setting the icons
accordingly. If I could set them via a function during binding would be
better.

Also, from a textbox during binding would work well for a couple of places
that I don't use a datagrid.

Thanks,

Tom
 
G

Guest

I actually usually bind to functions rather than directly to properties,
especially when binding to dates.

The only way in a grid though is to use a template column. You should be
able to change whichever column is in question to a template column, and then
edit the template. When you edit the template, set the binding to custom and
specify your method. You may want to also pass the container object so you
have access to the underlying data.
 
T

tshad

John Bailey said:
I actually usually bind to functions rather than directly to properties,
especially when binding to dates.

The only way in a grid though is to use a template column. You should be
able to change whichever column is in question to a template column, and
then
edit the template. When you edit the template, set the binding to custom
and
specify your method. You may want to also pass the container object so
you
have access to the underlying data.

How would I do this if I have a datagrid like following where I want to
format the date for the 1st column (Posted) using both an inline format
statement or call a function to apply the formatting. Same for the money
field (SalaryMax) :

<asp:DataGrid AllowPaging="true"
AllowCustomPaging="false"
PageSize="10"
PagerStyle-Visible="false"
Visible=false
AllowSorting="True"
AutoGenerateColumns="false"
CellPadding="3"
CellSpacing="0"
ID="DataGrid1"
runat="server"
ShowFooter="false"
ShowHeader="true"
OnSortCommand="SortDataGrid"
BorderWidth="1"
BorderColor="#999999"
style="width:800px">
<headerstyle HorizontalAlign="center" BackColor="#c0edee"
ForeColor="#2FABAD" Font-Bold="true" />
<alternatingitemstyle CssClass="alternateRows" />
<footerstyle HorizontalAlign="center" BackColor="#E8EBFD"
ForeColor="#3D3DB6" Font-Bold="true" />
<pagerstyle BackColor="white" />
<columns>
<asp:BoundColumn DataField="Posted"
HeaderText="Posted"
ReadOnly="true"
Visible="True"
ItemStyle-Width="50px"
ItemStyle-VerticalAlign="Top"
SortExpression="DatePosted">
<asp:BoundColumn DataField="Applied"
ReadOnly="true"
Visible="True"
ItemStyle-VerticalAlign="Top">
<itemstyle ForeColor="red" />
</asp:BoundColumn>
<asp:BoundColumn DataField="SalaryMax"
HeaderText="SalaryMax"
ReadOnly="true"
Visible="true"
ItemStyle-VerticalAlign="Top"/>
</columns>
</asp:DataGrid>

sub SetDateFormat(s as Sender, e as eventargs)
????
end sub

sub SetMoneyFormat(s as Sender, e as eventargs)
e.String.Format("{0:c}",CalculateYearly(Regex.Replace(WagesMin.Text,"\$|\,","")))
end sub

I have been applying the date formats in SQL and it has been mentioned that
it would be better to do this on the client.

How would I apply these and/or put the format directly on the column as
opposed to calling the function?

I am trying to find out how to do both as I do have situations where I need
to do more manipulations that just a format on the field.

Thanks,

Tom
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,073
Latest member
DarinCeden

Latest Threads

Top