Results 1 to 2 of 2

Thread: Urgent VB.net datalist control items in edit template

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2003
    Posts
    9

    Urgent VB.net datalist control items in edit template

    Hi guys,
    Im using vb.net and working with a datalist.

    I have labels, textboxes dropdownlist in the main item template.

    I also have labels, textboxes dropdownlist in the edit template

    which means when i click the edit button from the datalist list of records it brings me to another interface for editing.(where these textboxes etc will be displayed)

    Problem:

    Using

    DataList1.EditItemIndex = e.Item.ItemIndex
    CType(e.Item.FindControl("name_of_label"), Label).Text = objFAC_DES("FAC_DESC").ToString
    dont bother about objFAC_DES("FAC_DESC").ToString
    its a datareader... I ve checked all my sql query working perfectly in the code, somehow i can safely say that i've narrow down the problem to the datalist find control reference error.

    It cannot work:error says object reference is not set to instance

    This same code and method works for all the form elements in the main item template but not in the edit template.

    I've also tried the following:
    using page trace i manage to identify the ID of the form elements

    Dim myId As String = (CType(sender, DropDownList)).Parent.ClientID.ToString()
    where sender is the object passed into the edit function
    the id is something like "_clt0, _clt1"
    e.item.FindControl(myId).FindControl("lstDropDownList").text="Testing"
    I've checked my asp theres no nested form tags only one form

    I think it take more than a guru to solve this.
    Pls advice thanks.
    Last edited by evelin; Apr 30th, 2003 at 05:07 AM.

  2. #2
    Addicted Member Dmyze's Avatar
    Join Date
    Mar 2002
    Location
    Seattle
    Posts
    160
    I don't know if this will help, but here is a Datagrid routine I have that works: (I may have had the same prolbem until I started adding the 'Not Is Nothing' statements..

    VB Code:
    1. Private Sub dg_ItemCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles dg.ItemCreated
    2.  
    3.     Select Case e.Item.ItemType
    4.       Case ListItemType.Item, ListItemType.AlternatingItem, ListItemType.EditItem
    5.  
    6.         Dim cmdDelete As Button = e.Item.FindControl("cmdDelete")
    7.         Dim txtHTML As ActiveUp.HtmlTextBox.HtmlTextBox = e.Item.FindControl("HtmlTextBox1")
    8.  
    9.         If Not txtHTML Is Nothing Then
    10.           txtHTML.Fonts.Insert(0, "Tahoma")
    11.         End If
    12.  
    13.         If Not cmdDelete Is Nothing Then
    14.           Dim cdr As Common.DbDataRecord = e.Item.DataItem
    15.           Dim sName As String
    16.  
    17.           If Not cdr Is Nothing Then
    18.             sName = cdr.GetValue(1)
    19.           End If
    20.  
    21.           cmdDelete.Attributes.Add("onclick", "return confirm('Are you sure you want to delete " & sName & "?');")
    22.         End If
    23.     End Select
    24.  
    25.   End Sub
    -Daryl
    "Two More Rolls of Duct tape, and the world is mine!"
    VB.NET Guru

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width