By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,214 Members | 2,072 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,214 IT Pros & Developers. It's quick & easy.

Still having a problem with using a DataList

P: n/a
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
Jun 5 '07 #1
Share this Question
Share on Google+
5 Replies


P: n/a
On Jun 5, 7:30 pm, "Aussie Rules" <AussieRu...@nospam.nospamwrote:
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
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.

Jun 5 '07 #2

P: n/a
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?
Jun 6 '07 #3

P: n/a
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
--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net


"Aussie Rules" wrote:
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
Jun 6 '07 #4

P: n/a
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 (wa****@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.

Jun 12 '07 #5

P: n/a
Hi,

Sorry was away for a few days.

Yes this has resolved my problems.

Thanks all

"Walter Wang [MSFT]" <wa****@online.microsoft.comwrote in message
news:8W**************@TK2MSFTNGHUB02.phx.gbl...
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 (wa****@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.
Jun 13 '07 #6

This discussion thread is closed

Replies have been disabled for this discussion.