Converting System.Guid to string!

  • Thread starter Thread starter Jeff
  • Start date Start date
J

Jeff

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
 
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.
 
Back
Top