Hi all,

I bind an sql table to a datagrid. The table has a status column, this is
smallint. I would like to write "Busy" to the datagrid, if status=0, "Done",
if status=1, and "error" if status=2 and not 1,2,3.

How can I solve this problem?

Thank you very much in advance!

Best regards,
Bálint Tóth

re:datagrid question by don

don
Thu May 13 13:00:23 CDT 2004

If you're using a MS SQL Server, you could write an SQL statement to
retrieve the data from the table and use the SELECT CASE function to
translate the 1,2,3's into "Busy", "Done", "Error".

select
case status
when '0' then 'Busy'
when '1' then 'Done'
when '3' then 'Done'
end as status
from
someTable


Re: datagrid question by Balint

Balint
Fri May 14 06:28:08 CDT 2004

Thank you for your reply.

The second solution would be good (I change the status on the fly), but
unfortuntaly I am using winforms datagrid. How can I solve the problem in
case of a winforms datagrid?

Thanks in advance!

Regards,
Bálint Tóth

"Bin Song, MCP" <anonymous@discussions.microsoft.com> az alábbiakat írta a
következo üzenetben
news:32EB9616-2629-40DC-BD3E-E6F0BC01D59E@microsoft.com...
> Hi,
>
> Two way to do this:
> One is change the SQL statement that graps the data:
> Select StatusName = Case Status When 0 Then 'Busy' When 1 Then 'Done' When
2 Then 'Error' End From YourTable
> Then bind StatusName to the grid.
>
> Another solution is Binding dynamically:
> Private Sub DataGrid1_ItemDataBound(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DataGridItemEventArgs) Handles
DataGrid1.ItemDataBound
> If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType =
ListItemType.AlternatingItem Then
> Dim str as String
> Select Case e.Item.DataItem("Status")
> Case 0
> str = "Busy"
> Case 1
> str = "Done"
> Case 2
> str = "Error"
> End Select
> e.Item.Cells(Col_Status).Text = str
> End If
> End Sub
>
> Hope this helps
>
> Bin Song, MCP