how to display sql server uniqueidentifier (GUID) in a combo box in ASP.NET

G

Gopal Krish

I need to display uniqueidentifier (GUID) from a table in SQL Server
into a ASP.NET Web Page (Combo box). I'm using C#.

When I tried to display GUIDs in a combo box I get "System.Byte[]" for
all the items in the combo box.

Code :

ddSeverity.DataSource = A dataset is returned here;
ddSeverity.DataValueField = "Name";
ddSeverity.DataTextField = "Severity_ID";
ddSeverity.DataBind();

"Severity_ID" is actually a GUID (Uniqueidentifier) in a SQL server
table.

I need to display the GUIDS as hex values in the web page (Just as the
GUIDS are show as hex values in Query Analyzer) but its not showing
anything other than "System.Byte[]".

Any help is much appreciated.

Thanks
Gopal
 
W

wl

Probably there is a a better solution, but it looks you could do a cast in
the query:

select cast (MyguidField as varchar(40)) ...
 
G

Guest

Hi GOpal
Can you please tell me how u r getting the values from the database.As u
said i am not getting any error or "System.Byte[]" .
check how ur getting values from the database.
I have created table with Unique Identified gettig data into dataset and
binding ...displaying properly...
 
G

Gopal Krish

Hi,

This works but the guid displays as junk characters in the drop down.
I need to figure out a way to convert the guid to hex value while
reading it from the sql sever and then figure out a way to convert the
hex value to guid when sending it back to the sql server.

Any thoughts will be very helpful.

wl said:
Probably there is a a better solution, but it looks you could do a cast in
the query:

select cast (MyguidField as varchar(40)) ...


Gopal Krish said:
I need to display uniqueidentifier (GUID) from a table in SQL Server
into a ASP.NET Web Page (Combo box). I'm using C#.

When I tried to display GUIDs in a combo box I get "System.Byte[]" for
all the items in the combo box.

Code :

ddSeverity.DataSource = A dataset is returned here;
ddSeverity.DataValueField = "Name";
ddSeverity.DataTextField = "Severity_ID";
ddSeverity.DataBind();

"Severity_ID" is actually a GUID (Uniqueidentifier) in a SQL server
table.

I need to display the GUIDS as hex values in the web page (Just as the
GUIDS are show as hex values in Query Analyzer) but its not showing
anything other than "System.Byte[]".

Any help is much appreciated.

Thanks
Gopal
 

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

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top