473,804 Members | 3,147 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to perform functions upon 'bound' data? (asp .net)

Is there a way to perform functions upon databound data that is to be
used in a GridView? For example, in the following code where I am using
a GridView to display a resulting asp:SqlDataSour ce

<asp:GridView ID="GridView1" runat="server" AllowPaging="Tr ue"
AutoGenerateCol umns="False" CellPadding="4"
DataSourceID="S qlDataSource1" ForeColor="#333 333"
GridLines="None " Height="402px" Width="612px" AllowSorting="T rue"
PageSize="50">
<FooterStyle BackColor="#990 000" Font-Bold="True"
ForeColor="Whit e" />
<Columns>
<asp:BoundFie ld DataField="Fiel d1"
HeaderText="Fie ld1" SortExpression= "Field1" />
<asp:BoundFie ld DataField="Fiel d2"
HeaderText="Fie ld2" SortExpression= "Field2" />
<asp:BoundFie ld DataField="Fiel d3"
HeaderText="Fie ld3" SortExpression= "Field3" />
<asp:BoundFie ld DataField="Fiel d4"
HeaderText="Fie ld4" SortExpression= "Field4" />
<asp:BoundFie ld DataField="Fiel d5"
HeaderText="Fie ld5" SortExpression= "Field5" />
</Columns>
<SelectedRowSty le BackColor="#FFC C66" ForeColor="Navy "
Font-Bold="True" />
<PagerStyle BackColor="#FFC C66" ForeColor="#333 333"
HorizontalAlign ="Center" />
<HeaderStyle BackColor="#990 000" Font-Bold="True"
ForeColor="Whit e" />
<AlternatingRow Style BackColor="Whit e" />
<RowStyle BackColor="#FFF BD6" ForeColor="#333 333" />
</asp:GridView>

Is there something in Visual Studio 2005 Express Edition on the control
itself (somewhere in the properties) to perform an 'action' on a field
prior to insertion?

For example, if you have something formatted oddly in the dataset, and
you have a string Field1 in format "abcdefg" and you wanted to strip
"efg" before putting it into the gridview in the appropriate column.

Regards,
MurdockSE

Jul 12 '06 #1
2 2181
I am not totally sure about using functions in a gridview. You can
however use functions for your bound data in a datagrid or datalist.
<%# Function(contai ner.dataitem("F ield1"), myParam) %like so. Not
sure if this helps.

-Nathan

Jul 12 '06 #2
Hello MurdockSE,

You should be able to add an event handler for the RowDataBound event of the
GridView control to access row data after it is bound and before it is
rendered. Something like this:

void CustomersGridVi ew_RowDataBound (Object sender, GridViewRowEven tArgs e)
{

if(e.Row.RowTyp e == DataControlRowT ype.DataRow)
{
// Display the company name in italics.
e.Row.Cells[1].Text = "<i>" + e.Row.Cells[1].Text + "</i>";

}

}

--
enjoy - brians
http://www.limbertech.com
"mu*****@nc.rr. com" wrote:
Is there a way to perform functions upon databound data that is to be
used in a GridView? For example, in the following code where I am using
a GridView to display a resulting asp:SqlDataSour ce

<asp:GridView ID="GridView1" runat="server" AllowPaging="Tr ue"
AutoGenerateCol umns="False" CellPadding="4"
DataSourceID="S qlDataSource1" ForeColor="#333 333"
GridLines="None " Height="402px" Width="612px" AllowSorting="T rue"
PageSize="50">
<FooterStyle BackColor="#990 000" Font-Bold="True"
ForeColor="Whit e" />
<Columns>
<asp:BoundFie ld DataField="Fiel d1"
HeaderText="Fie ld1" SortExpression= "Field1" />
<asp:BoundFie ld DataField="Fiel d2"
HeaderText="Fie ld2" SortExpression= "Field2" />
<asp:BoundFie ld DataField="Fiel d3"
HeaderText="Fie ld3" SortExpression= "Field3" />
<asp:BoundFie ld DataField="Fiel d4"
HeaderText="Fie ld4" SortExpression= "Field4" />
<asp:BoundFie ld DataField="Fiel d5"
HeaderText="Fie ld5" SortExpression= "Field5" />
</Columns>
<SelectedRowSty le BackColor="#FFC C66" ForeColor="Navy "
Font-Bold="True" />
<PagerStyle BackColor="#FFC C66" ForeColor="#333 333"
HorizontalAlign ="Center" />
<HeaderStyle BackColor="#990 000" Font-Bold="True"
ForeColor="Whit e" />
<AlternatingRow Style BackColor="Whit e" />
<RowStyle BackColor="#FFF BD6" ForeColor="#333 333" />
</asp:GridView>

Is there something in Visual Studio 2005 Express Edition on the control
itself (somewhere in the properties) to perform an 'action' on a field
prior to insertion?

For example, if you have something formatted oddly in the dataset, and
you have a string Field1 in format "abcdefg" and you wanted to strip
"efg" before putting it into the gridview in the appropriate column.

Regards,
MurdockSE

Jul 12 '06 #3

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

Similar topics

99
5931
by: David MacQuigg | last post by:
I'm not getting any feedback on the most important benefit in my proposed "Ideas for Python 3" thread - the unification of methods and functions. Perhaps it was buried among too many other less important changes, so in this thread I would like to focus on that issue alone. I have edited the Proposed Syntax example below to take out the changes unecessary to this discussion. I left in the change of "instance variable" syntax (...
4
3578
by: Aaron Ackerman | last post by:
I am using typed datasets in an N-Tier Windows app using VB.NET. I know this posting cannot be fully explained in a single post that is why I am asking for someone to point me to a real world tutorial (in vb.net) that can show me how to use a bound Datagrid to it's fullest potential. I need to utilize the bound Datagrid in two modes. One were a bound Datagrid can be in edited directly utilizing bound combos and textbox right on the grid,...
3
1817
by: Mika | last post by:
Is it possible to perform functions on a recordset (rather than on the source database), e.g. COUNT, MAX etc The reason I would like to do this is because I have a hugely complex view which produces results with over 60 columns of data. I would like to display all data but also highlight individual "cells" in the table which have the highest (i.e. MAX) data for each column. I would also like totals at the bottom of each column. ...
0
1926
by: VbScripter | last post by:
In the code below, I have an editItemTemplate that will have to have a long list of ip's bound to it. The problem is that the lisbox is not seen by asp.net until after the datalist containing it is exposed. Is there a way to bind the ddl inside of an already databound templated column? Thanks , of course Michael
7
4265
by: | last post by:
Hello, I would like to do the following from a asp.net button click: <form method="POST" action="https://www.1234.com/trans_center/gateway/direct.cgi"> <input type="hidden" name="Merchant" value="Merchant Name"> <input type="hidden" name="OrderID" value="Unique OrderID value"> <input type="hidden" name="email" value="Customers email address (OPTIONAL)">
0
7788
by: Ed | last post by:
I've attached some VB.NET code I've hacked together (some taken from MS examples & newsgroup postings) that will perform a ping or IcmpSendEcho using the icmp.dll (see this for more info: http://support.microsoft.com/default.aspx?scid=kb;en-us;170591 ). The problem I have is in order to perform a discovery/ping of an entire subnet (192.168.1.* for instance) I have to do a FOR loop to itterate through all of the addresses. That it seems...
1
2125
by: Mike P | last post by:
Is it possible when populating a datagrid to populate a dropdownlist column based upon the value populated to another row in the datagrid? (i.e. I have a drop down which I want to populate differently for each row with user names based upon a UserRegionID which is also a column in the row). Since you don't actually know the value of the UserRegionID until the data is already bound to the datagrid, how do you do this?
2
319
by: murdock | last post by:
Is there a way to perform functions upon databound data that is to be used in a GridView? For example, in the following code where I am using a GridView to display a resulting asp:SqlDataSource <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AutoGenerateColumns="False" CellPadding="4" DataSourceID="SqlDataSource1" ForeColor="#333333" GridLines="None" Height="402px" Width="612px" AllowSorting="True" PageSize="50">...
2
3931
by: John Kotuby | last post by:
Hi guys, I am converting a rather complicated database driven Web application from classic ASP to ASP.NET 2.0 using VB 2005 as the programming language. The original ASP application works quite well, so at times it is tempting just to port parts of it over mostly as-is. In fact, one MSDN article I read suggested using straight HTML wherever possible to make the app more efficient and less resource demanding. On one page there are 2...
0
9587
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10588
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10324
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10085
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9161
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7623
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6857
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5662
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2998
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.