Dynamically Change a DataGrid Value

  • Thread starter Thread starter dauphian
  • Start date Start date
D

dauphian

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
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top