473,396 Members | 1,996 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.

Substitute Values in Column in Gridview

I have a Gridview bound to an SQLDataSource (see code below). The value of
the "DayOfWeek" column is actually an integer where 0 = Daily, 1=Sunday,
2=Monday, etc. How can I change what is displayed in the column from values
like 1or 2 to "Sunday", "Monday"?
============== Code =================
<asp:GridView ID="GridView1" runat="server" AllowPaging="True"
AllowSorting="True"

AutoGenerateColumns="False" DataSourceID="SqlDataSource1">

<Columns>

<asp:BoundField DataField="EventName" HeaderText="EventName"
SortExpression="EventName" />

<asp:BoundField DataField="DayOfWeek" HeaderText="DayOfWeek"
SortExpression="DayOfWeek" />

<asp:BoundField DataField="Occurs" HeaderText="Occurs"
SortExpression="Occurs" />

<asp:BoundField DataField="Location" HeaderText="Location"
SortExpression="Location" />

</Columns>

</asp:GridView>
Mar 11 '06 #1
1 1625
I finally found an example that I could apply. I created a Select Case
function named GetDayOfWeek to return the string I wanted for each case and
then replaced the Bound Column in the ASP code to:

<asp:TemplateField HeaderText="Day of Week">

<ItemTemplate>

<%#GetDayOfWeek(CInt(Eval("DayOfWeek")))%>

</ItemTemplate>

</asp:TemplateField>

Wayne
"Wayne Wengert" <wa***********@wengert.org> wrote in message
news:ut****************@tk2msftngp13.phx.gbl...
I have a Gridview bound to an SQLDataSource (see code below). The value of
the "DayOfWeek" column is actually an integer where 0 = Daily, 1=Sunday,
2=Monday, etc. How can I change what is displayed in the column from values
like 1or 2 to "Sunday", "Monday"?
============== Code =================
<asp:GridView ID="GridView1" runat="server" AllowPaging="True"
AllowSorting="True"

AutoGenerateColumns="False" DataSourceID="SqlDataSource1">

<Columns>

<asp:BoundField DataField="EventName" HeaderText="EventName"
SortExpression="EventName" />

<asp:BoundField DataField="DayOfWeek" HeaderText="DayOfWeek"
SortExpression="DayOfWeek" />

<asp:BoundField DataField="Occurs" HeaderText="Occurs"
SortExpression="Occurs" />

<asp:BoundField DataField="Location" HeaderText="Location"
SortExpression="Location" />

</Columns>

</asp:GridView>

Mar 11 '06 #2

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

Similar topics

13
by: anonymike | last post by:
Hello, I started working with the ObjectDataSource today. I have the select, and have been working on getting the update method to work. Here is the asp code for my Data source: ...
3
by: Carlos | last post by:
Hi all, I currently have a Gridview that doess sorting correctly using several fields. However, I do have a checkbox field that when it is checked I do not know how to make its value to persist...
1
by: Eric | last post by:
I have a GridView control that I want to sort on multiple columns when I click a particular column. For example, I display Last name + ", " + First name in the first column and display id in the...
3
by: Andrea | last post by:
The Gridview's RowDeleting event, give the power - cycling the e.Keys Dictionary, to discover the values of the Primary key fields of the dataset setup throught the DataKeyNames. Since I want to...
0
by: =?Utf-8?B?Vmlua2k=?= | last post by:
Hello Everyone, I have a gridview. I calculated some values in the gridview for the footer of the gridview so basically I am adding all the values that are displayed in the gridview for each...
2
by: desinerd | last post by:
Hi All. I am using a GridView to List contacts linked to a logged in User. I can successfully bind the Gridview with a DataTable. And the values in the GridView are correctly displayed. I...
0
by: =?Utf-8?B?UGhpbCBKb2huc29u?= | last post by:
Hi, I need to have a column in a gridview that cycles through a set of comma delimited values i.e. if you imagine a column where in one row the value might be "111,222" and in the next row it...
1
by: neobonzi | last post by:
Hello! I'm dynamically creating a GridView bound to a datatable using custom template columns using the following method: protected void ShowGrid(DataTable dt) { ...
8
by: hiranmaie | last post by:
Hi, I am having 3 textboxes and 1 gridview. I want to pass (reflect) the values from textboxes to gridview. I am not using the database here. I want to save the data directly from textboxes...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
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
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...
0
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...

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.