call this for your listbox even after databind, but don't insert if into
your source table
Listbox.Items.Insert(0, New ListItem("keine Nummer", "0"))
"One Handed Man" <terry_burnsREMOVE%FOR%NO%(E-Mail Removed)> schrieb im
Newsbeitrag news:etjkfn$(E-Mail Removed)...
> I set the binding up at design time. It builds without error, but refuses
to
> allow the insert because the control is bound to a data source.
>
>
>
> Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles Button1.Click
>
> Dim NR As DataRow = Ds1.Tables("People").NewRow
>
> Dim t As DataTable = Ds1.Tables("People")
>
> NR("FirstName") = "All Items"
>
> Ds1.Tables("People").Rows.InsertAt(NR, 0) <<<<<< ERROR Cannot insert when
> data source is selected
>
> End Sub
>
>
> --
> Regards - One Handed Man
>
> Author : Fish .NET & Keep .NET
>
> ==============================
> "Thomas Robertson" <(E-Mail Removed)> wrote in message
> news:%23puAlh$(E-Mail Removed)...
> > What exception do you get? I am using the below code and it works
> > fine...
> >
> > ' load the ProductList listbox
> > If Not (lbProductList Is Nothing) Then
> > lbProductList.DataSource = oStoreData.Products.GetProductQNav()
> > lbProductList.DataTextField = "name"
> > lbProductList.DataValueField = "code"
> > lbProductList.DataBind()
> > lbProductList.Items.Insert(0, "Product List")
> > lbProductList.Items(0).Value = "-"
> > lbProductList.Items.Insert(0, "-Select Product To View-")
> > lbProductList.Items(0).Value = ""
> > End If
> >
> > Maybe it is when you are binding it? I bind then do whatever else I
> have
> > to do afterwards. Have you stepped through it and found when it is
bombing
> > out on you? If that didn't help figure out where it is failing and post
> the
> > code. I am sure someone can figure it out.
> >
> > HTH,
> >
> > Tom
> >
> > "One Handed Man" <terry_burnsREMOVE%FOR%NO%(E-Mail Removed)> wrote
in
> > message news:eaDYZQ%(E-Mail Removed)...
> > > Scenario
> > > ---------
> > > Usng a data bound listbox to a table containing sorted data. ListBox
has
> > > sorted turned off so takes sorted data straight from the table.
> > > Problem
> > > ---------
> > > Want to be able to insert an item at start of list before sorted items
> > from
> > > table.
> > >
> > > 1.) cannot use listbox insert method when lb is databound because it
> > throws
> > > a runtime exception
> > > 2.) tried to insertAt( Object, 0 ) // at first position, but it
allways
> > goes
> > > to the end.
> > >
> > > So . . .
> > >
> > > Why is 2.) Happening and any ideas for coding around this problem ?
> > >
> > > Any help is appreciated
> > >
> > >
> > >
> > >
> > > --
> > > Regards - One Handed Man
> > >
> > > Author : Fish .NET & Keep .NET
> > >
> > > ==============================
> > >
> > >
> >
> >
>
>
|