473,397 Members | 1,960 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Still having a problem with using a DataList

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
5 1444
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Sansanee | last post by:
Hi, I am having problem using EmployeePrivateAdrUS.GetList through SAP.NET. I used the code below and get the error messgae that the method can not be reflected. I assume taht the problem arise...
3
by: mark kurten | last post by:
I have a soap message that looks like this. s = s & " <soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'" s = s & " xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'" s =...
0
by: Homa | last post by:
Hi to all, My database has two tables: order and orderItem. the order table has (idOrder, name, address, etc) and the orderItem table has (idOrder, idProduct, Quantity) I want to present the...
4
by: Charles | last post by:
I am still having problems with sessions crossing over from other sessions. What I mean by this is that Mary may get just some or all of Renae’s information. I think that what is going on with...
3
by: sheena81 | last post by:
hi, im still having problem with sql server connection. my server is not at the same place, it's at other country. the command that i have used is as below : <% Set demoConn =...
2
by: shamaila | last post by:
i want to retrieve primary key of parent table and then send this key to child table,as they have one-one relationship i've written code int i; string id = "SELECT MAX(c_id) FROM call_history";...
0
by: news.microsoft.com | last post by:
Hi, I am having problem using "DataGridViewCheckBoxColumn" in my project. The function dgvCheckBox_Clicked is called when CheckBox in DataGrid is clicked ( checked or unchecked). ...
1
by: Kelie | last post by:
Hello, I tried using xlrd to read an Excel file and kept getting this error: AttributeError: 'Book' object has no attribute 'mem' AttributeError: 'Book' object has no attribute 'mem' ...
0
by: Prakash | last post by:
hi, I have developed application using asp.net2.0 +ajax with history control of asp.net future. All application is working fine without adding history control. But when I add history control...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.