473,396 Members | 1,805 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Data Binding - ASP 2.0

I'm binding a column to a datagrid and would like to convert the column to
uppercase.

I notice that if I edit the GridView column, I can add formatting such as
{0:d} and {0:c} to the data item.

How can I convert this item to Uppercase?

I suppose I could do it via SQL, but I want to know how to do it using code.

Thanks
Feb 13 '06 #1
2 943
If you want formatting that isn't covered by the format strings, your
best bet is to handle the databinding events of your GridView.

<code>

protected void MyGridView_RowDataBound(object sender,
GridViewRowEventArgs e)
{
const myUppercaseColumnIndex = 1;
// don't handle headers or footers
if(e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Cells[myUppercaseColumnIndex].Text =
e.Row.Cells[myUp..].ToUpper();
}
}

</code>

Feb 14 '06 #2
Thanks for the response.

I have a couple issues though --

1) It didn't like the const line. Something about the = sign and receiving
an "no identifier" message. I simply hardcoded the column for now.

2) Apparently the ToUpper() function is not part of the Cell class or
whatever. No worky??
Also, where did you obtain the Grid events info, etc? Are there any books
that reference how to do all these things.

This is really cool stuff.
Thanks

"Flinky Wisty Pomm" <Pa********@gmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
If you want formatting that isn't covered by the format strings, your
best bet is to handle the databinding events of your GridView.

<code>

protected void MyGridView_RowDataBound(object sender,
GridViewRowEventArgs e)
{
const myUppercaseColumnIndex = 1;
// don't handle headers or footers
if(e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Cells[myUppercaseColumnIndex].Text =
e.Row.Cells[myUp..].ToUpper();
}
}

</code>

Feb 14 '06 #3

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

Similar topics

0
by: Ann Morris | last post by:
INTRODUCTION One of the most powerful aspects of .NET and Windows Forms is data binding. Data binding is the process of associating user interface (UI) elements with a data source to generate a...
16
by: D Witherspoon | last post by:
I am developing a Windows Forms application in VB.NET that will use .NET remoting to access the data tier classes. A very simple way I have come up with is by creating typed (.xsd) datasets. For...
1
by: matty.hall | last post by:
There's a lot of information out there about data-binding UI objects (i.e. derived from Control) to non-UI custom business objects. Is it possible to do the same without any UI being involved at...
0
by: NicK chlam via DotNetMonster.com | last post by:
this is the error i get System.Data.OleDb.OleDbException: Syntax error in INSERT INTO statement. at System.Data.Common.DbDataAdapter.Update(DataRow dataRows, DataTableMapping tableMapping) at...
19
by: Simon Verona | last post by:
I'm not sure if I'm going down the correct route... I have a class which exposes a number of properties of an object (in this case the object represents a customer). Can I then use this...
19
by: Larry Lard | last post by:
In the old days (VB3 era), there was a thing called the Data Control, and you could use it to databind controls on forms to datasources, and so (as the marketing speak goes), 'create database...
0
by: mjsterz | last post by:
I've been working with VB .NET for less than a year and this is the first time I've posted on one of these groups, so let me apologize beforehand if I'm being unclear, not posting my issue...
14
by: Rolf Welskes | last post by:
Hello, I have an ObjectDataSource which has as business-object a simple array of strings. No problem. I have an own (custom) control to which I give the DataSourceId and in the custom-control...
9
by: Anil Gupte | last post by:
After reading a tutorial and fiddling, I finally got this to work. I can now put two tables created with a DataTable class into a DataRelation. Phew! And it works! Dim tblSliceInfo As New...
3
by: Max | last post by:
Hello, I made a windows form with a combo box and 4 text boxes. All 5 objects should get their data from a data set which is populated in the form load method. The combo box has item ids. When...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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...
0
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
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...

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.