Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > A clearly instansiated object (a WebForm control) isn't instansiat

Reply
Thread Tools

A clearly instansiated object (a WebForm control) isn't instansiat

 
 
=?Utf-8?B?S3Jpc3RpYW4=?=
Guest
Posts: n/a
 
      02-07-2005
Hello,
When clicking on a button the selected item from the 1st listbox is supposed
to be added to the 2nd listbox:
The code:
Private Sub btnInfo_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnInfo.Click
Dim sVal As String
Me.lstKatInfo.SelectedIndex = -1
sVal = Me.lstKat.SelectedItem.Text
Me.lstKatInfo.Items.Add(sVal)
End Sub

When I enter text values in the first listbox everything works fine, but
when the
listbox items are added in the Page_Load event from a DataTable
this problems occurs.
Any ideas?

Thanks in advance,
Kristian
 
Reply With Quote
 
 
 
 
Karl Seguin
Guest
Posts: n/a
 
      02-07-2005

Kristian:
Are you rebinding the listbox on postback? My guess is that you are, and
therefore the user's selection is being overwritten with blank.

if not page.IsPOstBack then
lstKat.DataSource = myDataTable
lstKat.DataBind()
end if

also, in your btnInfo_Click you rally should make sure that there is a
selected item before retriving it's text...

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/


"Kristian" <(E-Mail Removed)> wrote in message
news(E-Mail Removed)...
> Hello,
> When clicking on a button the selected item from the 1st listbox is

supposed
> to be added to the 2nd listbox:
> The code:
> Private Sub btnInfo_Click(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles btnInfo.Click
> Dim sVal As String
> Me.lstKatInfo.SelectedIndex = -1
> sVal = Me.lstKat.SelectedItem.Text
> Me.lstKatInfo.Items.Add(sVal)
> End Sub
>
> When I enter text values in the first listbox everything works fine, but
> when the
> listbox items are added in the Page_Load event from a DataTable
> this problems occurs.
> Any ideas?
>
> Thanks in advance,
> Kristian



 
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
Moving value from popup Webform to main Webform? =?Utf-8?B?Vk1J?= ASP .Net 1 10-09-2006 05:15 PM
Using one webform to set a value on another webform =?Utf-8?B?bXN1aw==?= ASP .Net 1 07-12-2006 07:23 PM
web controls are not instansiated??? al ASP .Net 1 04-10-2004 09:08 PM
no code in webform using vs.net, but in webform using notepad timmso ASP .Net 1 12-12-2003 04:30 PM
Including WebForm Image Control in a Webform Table Control titof ASP .Net 0 07-24-2003 01:01 PM



Advertisments