468,292 Members | 1,499 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,292 developers. It's quick & easy.

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 23616
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Sandra | last post: by
1 post views Thread by vector | last post: by
3 posts views Thread by woodworker | last post: by
3 posts views Thread by Eagle | last post: by
1 post views Thread by SealedClassSingleton | last post: by
5 posts views Thread by Michael Primeaux | last post: by
2 posts views Thread by Jeff | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.