Hi,
I am still having a problem using a datalist control using VB.net
This is my code......
In the HTML page I have
<asp:DataList ID="DataList1" runat="server">
</asp:DataList>
In the codebehind file (code below) I get an error saying that NAME
datalist1 is not declared........
What am I doing wrong here????
Codebehind contents.....
Try
Dim SQLServerConnection As SqlConnection
Dim SqlConnectionCls As New clsSQL
Dim SqlDataAdapter As New SqlDataAdapter
Dim ds As New Data.DataSet
SQLServerConnection = SqlConnectionCls.Connect
Dim SqlCommand As New SqlCommand
With SqlCommand
.CommandType = Data.CommandType.StoredProcedure
.Connection = SQLServerConnection
.CommandTimeout = 15
.CommandText = "sproc_GetBannerAdvertDetails"
End With
SqlDataAdapter.SelectCommand = SqlCommand
SqlDataAdapter.Fill(ds, "data")
DataList1.DataSource = ds.Tables("data")
DataList1.DataBind()
Catch ex As Exception
End Try
Alexey Smirnov - 05 Jun 2007 21:41 GMT
> Hi,
>
[quoted text clipped - 43 lines]
>
> End Try
This probably due to some problem with the declaration of the
control.
What version of ASP.NET you're running?
VS.NET should create a declaration for each control on the form. A
place where that declaration is added depends on the version and a
type of project. For example, in a Web Application Project in ASP.NET
2.0 each web form has a special *.designer.vb file, that contains the
control declarations within a partial class. In ASP.NET 2.0 Web Site
Project the control declarations generated dynamically. In ASP.NET
1.0 /1.1 declarations were included in the code-behind class.
Try to delete the control from the page and add it again.
XOR - 06 Jun 2007 08:07 GMT
I have sometimes found that crazy problems like this go away when you remove
the control from the page and add it again.
You are using .net 2 right?
Peter Bromberg [C# MVP] - 06 Jun 2007 12:39 GMT
I think the issue here may be that you don't have anything inside your
Datalist to bind to, just an empty set of DataList tags. DataList needs to
have templates that define the HTML Elements that your data will be databound
to.
The best place to start is the ASP.NET quickstarts. Also, you have an empty
Catch block which buys you nothing other than to swallow any exceptions,
which is very bad coding form.
Peter

Signature
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net
> Hi,
>
[quoted text clipped - 43 lines]
>
> End Try
Walter Wang [MSFT] - 12 Jun 2007 03:58 GMT
Hi Aussie,
Since I didn't see you come back after community members replied, I'm
wondering if you think this issue has been solved or not. If not, please
feel free to let us know. Thanks.
Regards,
Walter Wang (wawang@online.microsoft.com, remove 'online.')
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Aussie Rules - 13 Jun 2007 18:10 GMT
Hi,
Sorry was away for a few days.
Yes this has resolved my problems.
Thanks all
> Hi Aussie,
>
[quoted text clipped - 13 lines]
> This posting is provided "AS IS" with no warranties, and confers no
> rights.