Parameter and Guid

S

shapper

Hello,

I am trying to define an ObjectDataSource parameter that is a Guid:

ObjectDataSource.DeleteParameters.Add(New Parameter("ID",
TypeCode.Int32))

However TypeCode does not have an option of Guid.

How should I do this?

Thanks,

Miguel
 
S

shapper

S

shapper

Hi Shapper
Please.. could you write a little more code....we can help you
better ;)
Example.. how do you bind a ObjectDataSource with data?? wich
webcontrol?
______________________
Jose A. Fernandez
blog:http://geeks.ms/blogs/fernandezja

Hi,

I am using an ASP.NET 3.5 ListView. Here is the code I am using:

ListView

Private Sub lvTags_Init(ByVal sender As Object, ByVal e As
EventArgs) Handles lvTags.Init

With lvTags
.DataKeyNames = New String() {"TagID"}
.DataSourceID = "odsTags"
.ID = "lvTags"
.InsertItemPosition = InsertItemPosition.FirstItem
End With

' Define templates
With lvTags
.EditItemTemplate = New
TagsTemplate(TemplateType.EditItemTemplate)
.InsertItemTemplate = New
TagsTemplate(TemplateType.InsertItemTemplate)
.ItemTemplate = New TagsTemplate(TemplateType.ItemTemplate)
.LayoutTemplate = New
TagsTemplate(TemplateType.LayoutTemplate)
End With

End Sub

ObjectDataSource

Private Sub odsTags_Init(ByVal sender As Object, ByVal e As
EventArgs) Handles odsTags.Init

' Define properties
With odsTags
.ID = "odsTags"
.DeleteMethod = "Delete"
.InsertMethod = "Insert"
.SelectMethod = "SelectAll"
.TypeName = "TagsManager"
.UpdateMethod = "Update"
End With

odsTags.DeleteParameters.Add(New Parameter("TagID",
TypeCode.Object))

odsTags.InsertParameters.Add(New Parameter("Text",
TypeCode.String))

odsTags.UpdateParameters.Add(New Parameter("TagID",
TypeCode.Object))
odsTags.UpdateParameters.Add(New Parameter("Text",
TypeCode.String))

End Sub

DELETE Method

<DataObjectMethodAttribute(DataObjectMethodType.Delete, True)> _
Public Shared Sub Delete(ByVal TagID As Object)
Dim database As New CodeDataContext
Dim tag = (From t In database.Tags _
Where t.TagID = TagID _
Select t).Single
database.Tags.DeleteOnSubmit(tag)
End Sub

I also tried:
Where t.TagID = New Guid(TagID.ToString)

When I debug the TagID input in Delete method is recognized as Guid
but is empty.

What am I doing wrong?

Thank You,
Miguel
 
S

shapper

Hi,

I am using an ASP.NET 3.5 ListView. Here is the code I am using:

ListView

Private Sub lvTags_Init(ByVal sender As Object, ByVal e As
EventArgs) Handles lvTags.Init

With lvTags
.DataKeyNames = New String() {"TagID"}
.DataSourceID = "odsTags"
.ID = "lvTags"
.InsertItemPosition = InsertItemPosition.FirstItem
End With

' Define templates
With lvTags
.EditItemTemplate = New
TagsTemplate(TemplateType.EditItemTemplate)
.InsertItemTemplate = New
TagsTemplate(TemplateType.InsertItemTemplate)
.ItemTemplate = New TagsTemplate(TemplateType.ItemTemplate)
.LayoutTemplate = New
TagsTemplate(TemplateType.LayoutTemplate)
End With

End Sub

ObjectDataSource

Private Sub odsTags_Init(ByVal sender As Object, ByVal e As
EventArgs) Handles odsTags.Init

' Define properties
With odsTags
.ID = "odsTags"
.DeleteMethod = "Delete"
.InsertMethod = "Insert"
.SelectMethod = "SelectAll"
.TypeName = "TagsManager"
.UpdateMethod = "Update"
End With

odsTags.DeleteParameters.Add(New Parameter("TagID",
TypeCode.Object))

odsTags.InsertParameters.Add(New Parameter("Text",
TypeCode.String))

odsTags.UpdateParameters.Add(New Parameter("TagID",
TypeCode.Object))
odsTags.UpdateParameters.Add(New Parameter("Text",
TypeCode.String))

End Sub

DELETE Method

<DataObjectMethodAttribute(DataObjectMethodType.Delete, True)> _
Public Shared Sub Delete(ByVal TagID As Object)
Dim database As New CodeDataContext
Dim tag = (From t In database.Tags _
Where t.TagID = TagID _
Select t).Single
database.Tags.DeleteOnSubmit(tag)
End Sub

I also tried:
Where t.TagID = New Guid(TagID.ToString)

When I debug the TagID input in Delete method is recognized as Guid
but is empty.

What am I doing wrong?

Thank You,
Miguel

I just solved it.
 
S

shapper

Hi Shapper...How you did??

______________________
Jose A. Fernandez
blog:http://geeks.ms/blogs/fernandezja

Hi,

I just solved it using an object.
The problem was not only that ... on some moments I had it working but
the Delete method missed the database.SubmitChanges() so it wasn't
being deleted so I though the problem was still with TagID.

Thank You,
Miguel
 

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

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top