|
-
Apr 30th, 2003, 05:01 AM
#1
Thread Starter
New Member
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.
-
Apr 30th, 2003, 04:55 PM
#2
Addicted Member
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:
Private Sub dg_ItemCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles dg.ItemCreated
Select Case e.Item.ItemType
Case ListItemType.Item, ListItemType.AlternatingItem, ListItemType.EditItem
Dim cmdDelete As Button = e.Item.FindControl("cmdDelete")
Dim txtHTML As ActiveUp.HtmlTextBox.HtmlTextBox = e.Item.FindControl("HtmlTextBox1")
If Not txtHTML Is Nothing Then
txtHTML.Fonts.Insert(0, "Tahoma")
End If
If Not cmdDelete Is Nothing Then
Dim cdr As Common.DbDataRecord = e.Item.DataItem
Dim sName As String
If Not cdr Is Nothing Then
sName = cdr.GetValue(1)
End If
cmdDelete.Attributes.Add("onclick", "return confirm('Are you sure you want to delete " & sName & "?');")
End If
End Select
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|