Is it possible to use convert a string to a GUID via inline C# within ASP.NET? In this example I would like to pass in a string for CustomerId
and have it formatted as a GUID as the stored procedure expects a Unique Identifier.
<asp:SqlDataSource ID="myDataSOurce" runat="server" ConnectionString="<%$ ConnectionStrings:myConnectionString %>" SelectCommand="GetUserData" SelectCommandType="StoredProcedure">
<SelectParameters>
<asp:Parameter DefaultValue="<% new Guid(customerId).ToString() %>" Name="CustomerId" Type="String" />
</SelectParameters>
</asp:SqlDataSource>
When I try this I get an error from SQL Server:
Error converting data type nvarchar to uniqueidentifier.