473,503 Members | 10,660 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

function call from boundcolumn

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

Nov 19 '05 #1
2 2141
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.

"tshad" wrote:
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

Nov 19 '05 #2
"John Bailey" <Jo********@discussions.microsoft.com> wrote in message
news:1D**********************************@microsof t.com...
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.Repl ace(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 "tshad" wrote:
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

Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3094
by: Ronny Sigo | last post by:
Hello all, On my form I have an unbound combobox with with 3 columns. It gets its values from a query. On the property sheet of the combobox its BoundColumn property is set to 2 At runtime I want...
3
1957
by: Nic | last post by:
Hey, Is it possible to do a databinding to a function, not to a property. Ex. Object : Invoices - Invoice Each Invoice has a collection of payments (an invoice can be paied in pieces) -...
1
1873
by: niki | last post by:
Hello. I have a problem with custom columns inside the datagrid. I've set up a datagrid that populates from a database; I can edit the datagrid values and update the db, so that's ok. (btw, it's...
4
2670
by: Randall Parker | last post by:
Using ASP.Net v1.1 with C#. I have an asp:DataGrid where one column is specified as follows: <asp:BoundColumn HeaderText="Serial" DataField="owner_serial_num"></asp:BoundColumn> I might get...
5
6606
by: Iain | last post by:
Hi All I have the code below (Using Delphi 2006 Developer to create an C# ASP.Net page to update a simple database table. When the page is fired I get the following error message ...
1
3310
by: rn5a | last post by:
A DataGrid has a BoundColumn which changes to a TextBox when the DataGrid is in the editable mode. The rest of the columns in the DataGrid are TemplateColumns. There's an EditCommandColumn as well....
4
1323
by: Ralf Rennartz | last post by:
Hello NG, i have the following function which works fine: Public Shared Function getFullDatagrid() As System.Web.UI.WebControls.DataGrid Dim myGrid As New...
0
1451
by: mesut | last post by:
Hi colleagues, I'm confused when to use Boundcolumn and when to use TemplateField in ASPX pages. If I use BoundField control how can I get the field value in code behind? If I use BoundField...
1
2687
by: SunshineInTheRain | last post by:
The following code is dynamic create dropdownmenu which data within pulled from database However, the code work well on IE but not on Firefox. On Firefox, the whole mouseover and mouseout function...
0
7207
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7294
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7361
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7470
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4693
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3183
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3173
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1523
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
749
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.