"Cor Ligthert" <(E-Mail Removed)> wrote in message
news:ONm1o%(E-Mail Removed)...
> Brian,
>
> I tested your problem. The code beneath gave me a datalist what looks like
> this.
>
> 1 (E-Mail Removed)
> 2 (E-Mail Removed)
>
>
> \\\
> Dim dt As New DataTable
> dt.Columns.Add("Id")
> dt.Columns.Add("EmailAdres")
> dt.Rows.Add(dt.NewRow)
> dt.Rows.Add(dt.NewRow)
> dt.Rows(0)(0) = "2"
> dt.Rows(1)(0) = "1"
> dt.Rows(0)(1) = "(E-Mail Removed)"
> dt.Rows(1)(1) = "(E-Mail Removed)"
> dt.DefaultView.Sort = "Id"
> dataList1.DataSource = dt.DefaultView
> dataList1.DataBind()
> ///
>
> I hope this helps?
Unfortunately I had tried this (and listed this in my orignal post). It
wasn't sorting it by guid either. It did put me on the right track though.
On further inspection, I found that the default view was indeed sorted, and
that I had fields in the properties box in the form designer. I deleted
these (so now there were no databound variables set in the form designer)
and set the DataTextField & DataValue field in code. The final code (that
works!) is:
datGroupAdmin.tblUser.DefaultView.Sort = "UserEmail"
lstGroupAdmin.DataSource = datGroupAdmin.tblUser.DefaultView
lstGroupAdmin.DataValueField = "UserId"
lstGroupAdmin.DataTextField = "UserEmail"
lstGroupAdmin.DataBind()
All the more reason not to trust Microsoft's form designer. It is possible
to build web forms without it, but some of the code required to do this is
tedious (try building a html table in code ;-) - yes I have done it as part
of a page template).
--
Brian Barnes
Now to apply that code to all the other datalists :-(