Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / February 2006

Tip: Looking for answers? Try searching our database.

Data Binding - ASP 2.0

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
dm1608 - 13 Feb 2006 22:17 GMT
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
Flinky Wisty Pomm - 14 Feb 2006 09:22 GMT
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>
dm1608 - 14 Feb 2006 15:06 GMT
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

> If you want formatting that isn't covered by the format strings, your
> best bet is to handle the databinding events of your GridView.
[quoted text clipped - 14 lines]
>
> </code>

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.