473,379 Members | 1,520 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,379 software developers and data experts.

Dynamically Change a DataGrid Value

Greetings,

I have a dataSet that I am loading into a dataGrid where one of the
columns values is simply one letter. I need to be able to assign that
letter to word:

BoundColumn type = new BoundColumn();
type.DataField = "type";
type.DataFormatString = checkType("{0}");
type.HeaderText = "Type";
type.HeaderStyle.Font.Bold = true;

public string checkType(object type)
{
string checkType = (string)type.ToString();

switch (checkType)
{
case "S":
return "Series";
case "R":
return "Random";
default:
return "Unknown!";
}
}

This is all being done in codebehind and currently it just displays
Unknown! on the page. So I think the values of S or R are not being
passed correctly to check this, or I am doing something wrong.

Thanks in advance!

-Kevyn

Jun 4 '06 #1
1 3598
Hi

Have you tried to attach an event handler in for the
dataGrid.OnDataBound or OnDataBinding to trigger the switch statement.
Works only in .net 2.0 I think (GridView).

Peter
da******@gmail.com wrote:
Greetings,

I have a dataSet that I am loading into a dataGrid where one of the
columns values is simply one letter. I need to be able to assign that
letter to word:

BoundColumn type = new BoundColumn();
type.DataField = "type";
type.DataFormatString = checkType("{0}");
type.HeaderText = "Type";
type.HeaderStyle.Font.Bold = true;

public string checkType(object type)
{
string checkType = (string)type.ToString();

switch (checkType)
{
case "S":
return "Series";
case "R":
return "Random";
default:
return "Unknown!";
}
}

This is all being done in codebehind and currently it just displays
Unknown! on the page. So I think the values of S or R are not being
passed correctly to check this, or I am doing something wrong.

Thanks in advance!

-Kevyn


Jun 5 '06 #2

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

Similar topics

0
by: Billy | last post by:
I have a web page with a control (Control#A) on it. The control (#A) has a control (Control#B) on it which displays an exception message when set and displayed. I am creating a simple datagrid...
2
by: Saravanan Rathinavelu | last post by:
Need to know how to modify the <asp:BoundColumn/> to N/A when the datafield value comes in as negative quantity and color it different on the ASP.Net DataGrid, help pl. thanks -Saravanan.R-
6
by: John Ruiz | last post by:
Greetings, I originally posted this to microsoft.public.dotnet.framework.aspnet.datagridcontrol two weeks ago, but no one was able to answer. I am unable to dynamically add columns to a...
0
by: Diane Yocom | last post by:
I'm very new to ASP.Net and probably jumped in a little over my head, but... I'm trying to create a user control that will control navigation through my site. It's sortof like Amazon.com, where...
2
by: Quentin Huo | last post by:
Hi: I have a user control and I want to dynamically create a Label control and TextBox control when the button "add more author name" is clicked. I did like this: 1. there is a...
4
by: Shiju Poyilil | last post by:
Hello EveryBody, I have a dropdownlist with some values as .net server controls & a button , on clicking a button i need to generate the choosen contorl dynamically. I am giving a small glimpse...
5
by: Aaron Ackerman | last post by:
I have a bound combobox the appears on a cell within the column of my bound grid when the user clicks on a cell n(In my vb.net WinForm app). I am trying to allow the adding of an item to that bound...
4
by: sydney.luu | last post by:
Hello, I would greatly appreciate if someone can show me how to dynamically build a Repeater with unknown number of columns at design time. I have looked various threads in this newsgroup,...
7
by: rsaffy | last post by:
I am having trouble with my dynamically created button's event handling. I read that the buttons need to be recreated on every trip to the server, but how exactly do you do that when the datagrid...
6
by: ree321 | last post by:
I have a linkbutton which is added to a column in a datagrid dynamically using a template I created. When I change the data in it by not databinding and then when I later retreive the data from the...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...

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.