Alter Data DataSet of one DataGrid (urgent)

  • Thread starter Thread starter Ahmet
  • Start date Start date
A

Ahmet

Hi all;

I have an application in which I use dataset - dataview pair to show some
values
to users.

On database this is my sample table named members

no type name
---- ------ ---------
1 N name value
2 S xyz value

and on my program I have some hard coded values about type descriptions like
N -> Never
Y -> Sometimes etc
....
...

My probmel is that I must show the description values on datagrid instead of
showing
type values.
I mean when I create dataset and bind it to datagrid, on grid Iwant to show
"Sometimes"
not "S"

Is there any effective way to do this ?


ps: Adding hardcoded values to a new table on database and joining these two
tables is
not desired solution :(
 
Create another talbe called lookup

In that put the keys between the 2... that way, you don't need to create a
new table in your database, even though that would probably be the best
idea....

-CJ
 
Could you please show me how to join this table in memory and show them in
dataset ?
Thanksin advance..
 
Ahmet,

Create a custom DataGridColumnStyle inherited from
System.Windows.Forms.DataGridTextBoxColumn. Override its SetColumnValueAtRow
and GetColumnValueAtRow methods to perform this translation on the fly.
 
Thanks Dimitry this will work;
Could you please tell me how can I override SetColumnValueAtRow ?




Dmitriy Lapshin said:
Ahmet,

Create a custom DataGridColumnStyle inherited from
System.Windows.Forms.DataGridTextBoxColumn. Override its SetColumnValueAtRow
and GetColumnValueAtRow methods to perform this translation on the fly.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

Ahmet said:
Hi all;

I have an application in which I use dataset - dataview pair to show some
values
to users.

On database this is my sample table named members

no type name
---- ------ ---------
1 N name value
2 S xyz value

and on my program I have some hard coded values about type descriptions like
N -> Never
Y -> Sometimes etc
...
..

My probmel is that I must show the description values on datagrid
instead
of
showing
type values.
I mean when I create dataset and bind it to datagrid, on grid Iwant to show
"Sometimes"
not "S"

Is there any effective way to do this ?


ps: Adding hardcoded values to a new table on database and joining these two
tables is
not desired solution :(
 
In C#:

internal class MyColumn: DataGridTextBoxColumn
{
// ...

public override void SetColumnValueAtRow(
CurrencyManager source,
int rowNum,
object value)
{
// Your code here.
}
}

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

Ahmet said:
Thanks Dimitry this will work;
Could you please tell me how can I override SetColumnValueAtRow ?




Dmitriy Lapshin said:
Ahmet,

Create a custom DataGridColumnStyle inherited from
System.Windows.Forms.DataGridTextBoxColumn. Override its SetColumnValueAtRow
and GetColumnValueAtRow methods to perform this translation on the fly.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

Ahmet said:
Hi all;

I have an application in which I use dataset - dataview pair to show some
values
to users.

On database this is my sample table named members

no type name
---- ------ ---------
1 N name value
2 S xyz value

and on my program I have some hard coded values about type
descriptions
like
N -> Never
Y -> Sometimes etc
...
..

My probmel is that I must show the description values on datagrid
instead
of
showing
type values.
I mean when I create dataset and bind it to datagrid, on grid Iwant to show
"Sometimes"
not "S"

Is there any effective way to do this ?


ps: Adding hardcoded values to a new table on database and joining
these
two
tables is
not desired solution :(
 
Back
Top