Re: DataGrid Column Headers
Greg Rothlander wrote:
> Any suggestions would be very much appreciated.
Use the ItemDataBound event. It's fired for headers and footers as well
as items. If the object passed is a header, populate the header's cells
with the text you want.
--
There are 10 kinds of people. Those who understand binary and those who
don't.
http://code.acadx.com
Re: DataGrid Column Headers
This seems to be what I want, but I'm not having any luck pulling out the
current value of the header. Can you give me some items? I just need to
take what is currently there (the default column names from SQL) and translate
them using my own translation function, or it would be nice if I could somehow
get SQL to use the column descriptions and not the column names to build
my DataSet. Anyway, Here is basically what I want to do... of course this
doesn't work because I can not read the currect header value.
Any help or suggestions would be very much appreciated.
Thanks,
Greg
private void DataGrid1_ItemDataBound(object s, DataGridItemEventArgs e)
{
if (e.Item.ItemType.ToString() == "Header")
{
e.Item.Cells[0].Text = GetFieldDesc(e.Item.Cells[0].Text);
}
}
private string GetFieldDesc(string fieldName)
{
string[] strDesc = new string[] {"Last Name","First Name"};
string[] strSQLColumn = new string[] {"LName","MName"};
int theIndex = Array.IndexOf(strSQLColumn,fieldName);
if(theIndex < 0)
{
return fieldName;
}
else
{
return strDesc[theIndex];
}
}
"Frank Oquendo" <franko@acadx.com> wrote:
>Greg Rothlander wrote:
>
>> Any suggestions would be very much appreciated.
>
>Use the ItemDataBound event. It's fired for headers and footers as well
>as items. If the object passed is a header, populate the header's cells
>with the text you want.
>
>--
>There are 10 kinds of people. Those who understand binary and those who
>don't.
>
>http://code.acadx.com
>
>
Re: DataGrid Column Headers
What we decided to do was Use Stored procedures we pas in conuntry code and
Select XX , YY From Table As cXX, cYY
I think you will find this approach preferable.
"Greg Rothlander" <j.rothlander@att.net> wrote:
>
>This seems to be what I want, but I'm not having any luck pulling out the
>current value of the header. Can you give me some items? I just need to
>take what is currently there (the default column names from SQL) and translate
>them using my own translation function, or it would be nice if I could somehow
>get SQL to use the column descriptions and not the column names to build
>my DataSet. Anyway, Here is basically what I want to do... of course this
>doesn't work because I can not read the currect header value.
>
>Any help or suggestions would be very much appreciated.
>
>Thanks,
>Greg
>
>
>private void DataGrid1_ItemDataBound(object s, DataGridItemEventArgs e)
>{
> if (e.Item.ItemType.ToString() == "Header")
> {
> e.Item.Cells[0].Text = GetFieldDesc(e.Item.Cells[0].Text);
> }
>}
>
>private string GetFieldDesc(string fieldName)
>{
> string[] strDesc = new string[] {"Last Name","First Name"};
> string[] strSQLColumn = new string[] {"LName","MName"};
>
> int theIndex = Array.IndexOf(strSQLColumn,fieldName);
> if(theIndex < 0)
> {
> return fieldName;
> }
> else
> {
> return strDesc[theIndex];
> }
>}
>
>"Frank Oquendo" <franko@acadx.com> wrote:
>>Greg Rothlander wrote:
>>
>>> Any suggestions would be very much appreciated.
>>
>>Use the ItemDataBound event. It's fired for headers and footers as well
>>as items. If the object passed is a header, populate the header's cells
>>with the text you want.
>>
>>--
>>There are 10 kinds of people. Those who understand binary and those who
>>don't.
>>
>>http://code.acadx.com
>>
>>
>