Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ListView. Please, really need help. Thank you.

Reply
Thread Tools

ListView. Please, really need help. Thank you.

 
 
shapper
Guest
Posts: n/a
 
      01-31-2008
Hello,

I created a Net 3.5 ListView at runtime by implementing ITemplate.

The ListView displays the records and I am able to delete a record.

However, I am not able to insert or update a record.

For example, on the EditItemTemplate I added a custom control named
Form.

This control is nothing more then a groups of TextBoxes, Labels and 2
buttons: Update and Cancel.

When one of the buttons is clicked the custom control Form fires an
Event where I can determine which button was pressed.

My problem is, after knowing that Update was clicked, to update the
record in the database.

I tried everything I could think of.

Could someone please let me know what I should do?

Here is my ListView code:

Private Sub ldsTags_Init(ByVal sender As Object, ByVal e As
EventArgs) Handles ldsTags.Init
With ldsTags
.ContextTypeName = "CodeDataContext"
.EnableDelete = True
.EnableInsert = True
.EnableUpdate = True
.TableName = "Tags"
.ID = "ldsTags"
End With
End Sub

Private Sub ldsTags_Selecting(ByVal sender As Object, ByVal e As
LinqDataSourceSelectEventArgs) Handles ldsTags.Selecting
Dim database As New CodeDataContext
Dim tags = From t In database.Tags _
Select t.TagID, _
t.Text, _
Active = t.FilesTags.Any Or t.ArticlesTags.Any
e.Result = tags
End Sub

Private Sub lvTags_ItemDeleting(ByVal sender As Object, ByVal e As
ListViewDeleteEventArgs) Handles lvTags.ItemDeleting

Dim database As New CodeDataContext
Dim tag = (From t In database.Tags _
Where t.TagID = New
Guid(lvTags.DataKeys(e.ItemIndex).Value.ToString)) .Single
database.Tags.DeleteOnSubmit(tag)
database.SubmitChanges()
End Sub

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

With lvTags
.DataKeyNames = New String() {"TagID"}
.DataSourceID = "ldsTags"
.ID = "lvTags"
.InsertItemPosition = InsertItemPosition.FirstItem
End With
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

Private Sub lvTags_Load(ByVal sender As Object, ByVal e As
EventArgs) Handles lvTags.Load
lvTags.DataBind()
End Sub

Thank you,

Miguel
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Profile ... really need help. Thank You. shapper ASP .Net 0 01-17-2007 01:25 AM
Can you tell me how to use "AND" here. It's really urgent. Thank You. Miguel Dias Moura ASP .Net 2 06-22-2004 07:58 AM
Drop Down List and AutoPostBack. Really urgent. Thank You Very Much Miguel Dias Moura ASP .Net 2 04-05-2004 04:51 PM
Thank You CJ, Thank Mike! mytho Computer Support 7 11-23-2003 06:50 AM



Advertisments