473,320 Members | 1,991 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Converting System.Guid to string!

ASP.NET 2.0

I have a GridView on my webpage. As one of its columns I've put a
HiddenField into a TemplateField. The porpose of this HiddenField is to hold
the ID of the row. Each row in the GridView shows a purchase order. This ID
column shows the ID of the purchase order. So if the user wants to delete
this purchase order then the value in the HiddenField is sent into a stored
procedure and updates the database....

So that's why I created a hiddenfield... If you know about a better
approach, then please please tell me...

Here I try to assign a System.Guid value to the hiddenfield. But this gives
a compile error:
(Cannot convert type 'System.Guid' to 'string')
HiddenField hidden = (HiddenField)e.Row.FindControl("Id");
hidden.Value = (string)message.Id;

This is the markup of my hiddenfield
<asp:TemplateField>
<ItemTemplate>
<asp:HiddenField ID="Id" runat="server" />
</ItemTemplate>
</asp:TemplateField>

If it is possible to convert System.Guid to string then please tell me
how... If this should be done from another approach then please tell me
how...

Best Regards!

Jeff
Apr 16 '07 #1
2 23928
What is wrong with

string g = System.Guid.NewGuid().ToString();

"Jeff" <it************@hotmail.com.NOSPAMwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
ASP.NET 2.0

I have a GridView on my webpage. As one of its columns I've put a
HiddenField into a TemplateField. The porpose of this HiddenField is to
hold the ID of the row. Each row in the GridView shows a purchase order.
This ID column shows the ID of the purchase order. So if the user wants to
delete this purchase order then the value in the HiddenField is sent into
a stored procedure and updates the database....

So that's why I created a hiddenfield... If you know about a better
approach, then please please tell me...

Here I try to assign a System.Guid value to the hiddenfield. But this
gives a compile error:
(Cannot convert type 'System.Guid' to 'string')
HiddenField hidden = (HiddenField)e.Row.FindControl("Id");
hidden.Value = (string)message.Id;

This is the markup of my hiddenfield
<asp:TemplateField>
<ItemTemplate>
<asp:HiddenField ID="Id" runat="server" />
</ItemTemplate>
</asp:TemplateField>

If it is possible to convert System.Guid to string then please tell me
how... If this should be done from another approach then please tell me
how...

Best Regards!

Jeff

Apr 16 '07 #2


System.Guid.NewGuid().ToString("N")

That might help.
hidden.Value = Convert.ToString( myguid )
Those are some options.

I usually do the ToString("N") for the web, so I don't have extra chars in
there.


"Jeff" <it************@hotmail.com.NOSPAMwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
ASP.NET 2.0

I have a GridView on my webpage. As one of its columns I've put a
HiddenField into a TemplateField. The porpose of this HiddenField is to
hold
the ID of the row. Each row in the GridView shows a purchase order. This
ID
column shows the ID of the purchase order. So if the user wants to delete
this purchase order then the value in the HiddenField is sent into a
stored
procedure and updates the database....

So that's why I created a hiddenfield... If you know about a better
approach, then please please tell me...

Here I try to assign a System.Guid value to the hiddenfield. But this
gives
a compile error:
(Cannot convert type 'System.Guid' to 'string')
HiddenField hidden = (HiddenField)e.Row.FindControl("Id");
hidden.Value = (string)message.Id;

This is the markup of my hiddenfield
<asp:TemplateField>
<ItemTemplate>
<asp:HiddenField ID="Id" runat="server" />
</ItemTemplate>
</asp:TemplateField>

If it is possible to convert System.Guid to string then please tell me
how... If this should be done from another approach then please tell me
how...

Best Regards!

Jeff


Apr 16 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Sandra | last post by:
I am trying to convert a string into a uniqueidentifier by using the following code string contrID = Request.Params["oId" SqlGuid sqlID = SqlGuid.Parse(contrID I am then putting sqlID into my...
1
by: vector | last post by:
I've got an application that generates GUIDs. A lot of GUIDs. Lots of GUIDs that end up in files on disk, taking up space. I'd like to continue using the Guid.NewGuid() function as my unique tag...
3
by: woodworker | last post by:
I have to create a COM dll from c# to use within old code. Every time I build I get a new guid. I have tried to use the phrase before a class or interface, but the compiler won't build due to the...
3
by: Eagle | last post by:
How do I convert a Guid to a string? I am trying to retrieve a value from a dataview into a string variable: CurrentValue = drv(strColumn) and it works fine until the strColumn is a guid...
5
by: rcolby | last post by:
Evening, Wondering if someone can point me in the right direction, on how I would compare a system.guid with a system.byte. system.guid (pulled from sql server table with a data type of...
3
by: dew | last post by:
I have a stored procedure that retrieves the id of a client table, which is a guid To get that id, I have dim clientid as guid = GetClientID("OrgName") The GetClientID returns a string,...
1
by: SealedClassSingleton | last post by:
Hi, When calling a stored procedure on a SQL 2005 DB with the managed SQL ADOprovider I got the following exception: Syntax error converting character string to uniqueidentifier when I use...
5
by: Michael Primeaux | last post by:
I have a simple .NET 2.0 web service created with VS.NET 2005 with a single web method with the following signature: void HelloWorld(Guid parameter1); When calling this method I receive the...
2
by: Jeff | last post by:
ASP.NET 2.0 I'm wondering how to convert a string into a System.Guid! I have this code where I want to use the convert: Message.DeleteMessage(hidden.Value);. Here DeleteMessage wants an...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.