473,809 Members | 2,787 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Dropdownlist,Da taTextField,Dat aValueField ?

Sam
I want to create dropdownlist where DataTextField and DataValueField are
extract from table gldate.

Example
Dropdownlist -> Jan-2005
-> Feb-2005
...
...
-> Dec-2005

Table gldate
============
DataTextField DataValueField
--------------------------------
Jan-2005 200501
Feb-2005 200502
.... ...
.... ...
Dec-2005 200512
Error
=====
Description: An error occurred during the compilation of a resource required
to service this request. Please review the following specific error details
and modify your source code appropriately.

Compiler Error Message: BC30188: Declaration expected.

Source Error:
Line 5: Dim cnSQL as New System.Data.Sql Client.SqlConne ction()
Line 6:
Line 7: cnSQL.Connectio nString = "Password=88;Pe rsist Security Info=True;
User ID=88;Initial Catalog=JDE_ERP _ARCHIVAL;Data Source=SQLSVR"
Line 8:
Line 9: cnSQL.Open()

Source File: C:\Documents and Settings\samuel lai\My
Documents\Heade r\NewFile.aspx Line: 7
Search.aspx
===========
<%@ Page Language="VB" %>
<%@ import Namespace="Syst em.Data" %>
<%@ import Namespace="Syst em.Data.SqlClie nt" %>
<script runat="server">
Dim cnSQL as New System.Data.Sql Client.SqlConne ction()

cnSQL.Connectio nString = "Password=88;Pe rsist Security Info=True; User
ID=88;Initial Catalog=JDE_ERP _ARCHIVAL;Data Source=SQLSVR"

cnSQL.Open()

Dim GLDate as New SQLCommand ("select * from gldate",cnSQL)

Dim dr as SQLDataReader = GLDate.ExecuteR eader

Do While dr.Read

End DO

dr.Close
GLDate = Nothing
dr = Nothing

</script>
<html>
<head>
</head>
<body>
<form runat="server">
<asp:DropDownLi st id="DropDownLis t1" runat="server"
OnSelectedIndex Changed="DropDo wnList1_Selecte dIndexChanged" DataSource="<%#
SqlDataSourceCo ntrol2 %>" DataTextField=" gl_date"
DataValueField= "gl_date"></asp:DropDownLis t>
</form>
</body>
</html>
Please advise.

Many thanks.
Nov 19 '05 #1
1 2923
A server script on the page can contain member declarations only, in the
same way as a class can. You should declare a method and put he code inside
the method.

Eliyahu

"Sam" <cy********@hot mail.com> wrote in message
news:O5******** ********@tk2msf tngp13.phx.gbl. ..
I want to create dropdownlist where DataTextField and DataValueField are
extract from table gldate.

Example
Dropdownlist -> Jan-2005
-> Feb-2005
...
...
-> Dec-2005

Table gldate
============
DataTextField DataValueField
--------------------------------
Jan-2005 200501
Feb-2005 200502
... ...
... ...
Dec-2005 200512
Error
=====
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: BC30188: Declaration expected.

Source Error:
Line 5: Dim cnSQL as New System.Data.Sql Client.SqlConne ction()
Line 6:
Line 7: cnSQL.Connectio nString = "Password=88;Pe rsist Security Info=True;
User ID=88;Initial Catalog=JDE_ERP _ARCHIVAL;Data Source=SQLSVR"
Line 8:
Line 9: cnSQL.Open()

Source File: C:\Documents and Settings\samuel lai\My
Documents\Heade r\NewFile.aspx Line: 7
Search.aspx
===========
<%@ Page Language="VB" %>
<%@ import Namespace="Syst em.Data" %>
<%@ import Namespace="Syst em.Data.SqlClie nt" %>
<script runat="server">
Dim cnSQL as New System.Data.Sql Client.SqlConne ction()

cnSQL.Connectio nString = "Password=88;Pe rsist Security Info=True; User
ID=88;Initial Catalog=JDE_ERP _ARCHIVAL;Data Source=SQLSVR"

cnSQL.Open()

Dim GLDate as New SQLCommand ("select * from gldate",cnSQL)

Dim dr as SQLDataReader = GLDate.ExecuteR eader

Do While dr.Read

End DO

dr.Close
GLDate = Nothing
dr = Nothing

</script>
<html>
<head>
</head>
<body>
<form runat="server">
<asp:DropDownLi st id="DropDownLis t1" runat="server"
OnSelectedIndex Changed="DropDo wnList1_Selecte dIndexChanged" DataSource="<%# SqlDataSourceCo ntrol2 %>" DataTextField=" gl_date"
DataValueField= "gl_date"></asp:DropDownLis t>
</form>
</body>
</html>
Please advise.

Many thanks.

Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
2810
by: Stanley J Mroczek | last post by:
How do you load a dropdownlist when edit is clicked in a datagrid ? <Columns> <asp:BoundColumn DataField="OptionDescription" ItemStyle-Wrap="True" HeaderText="Option Description"></asp:BoundColumn> <asp:TemplateColumn runat="server" HeaderText="Id Type Option" "> <itemtemplate> <asp:label runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "TypeOption") %>' /> <asp:label runat="server" ID="LlbTypeOption" Visible=False...
5
14268
by: TOm | last post by:
How do I bind a SqlDataReader to a dropdownlist box? I know how to construct a SqlDataReader dr and get the values. Buit how do I bind it to a DropDownList box in C#? This does not work cboUsers.DataSource = dr; cboUsers.Items.Clear(); cboUsers.DataTextField = dr.GetValue(1).ToString();
5
2665
by: DC Gringo | last post by:
I have a dropdownlist that, upon form submission, I'd like to maintain the selected value when I get my result...how do I do that? <asp:dropdownlist Font-Size="8" id="ddlCommunities" runat="server" Width="100"></asp:dropdownlist> Sub RunReport_OnClick(sender As Object, e As System.EventArgs) _sqlStmt &= " AND tblSurvey1.clnGUID = '" &
8
1676
by: tshad | last post by:
Can you databind a dropdownlist to another dropdownlist? I have 2 identical list. I am getting my data from a DataReader, so as soon as I have bound the first DDL, I can't do it again to the next as the dataReader can only be read once. I tried: ExperienceLevel.DataSource=dbReader ExperienceLevel.DataTextField= "Description"
0
1835
by: Daniel Doyle | last post by:
Hello and apologies in advance for the amount of code in this post. I've also sent this message to the Sharepoint group, but thought that ASP.NET developers may also be able to help, even though it's a Sharepoint WebPart. I'm trying to do something fairly simple, create a datagrid that displays where and when a person works and allows them to change some of the information via DropDownLists. When the user clicks to edit a row, three of...
11
5818
by: Santosh | last post by:
Dear all , i am writting following code. if(Page.IsPostBack==false) { try { BindSectionDropDownlist();
1
7238
by: Jason Wilson | last post by:
I have two dropdownlists that are bound to the same datasource and I have a couple of questions: 1) Because they are bound to the same datasource, I am assuming that they only make 1 round trip to the DB server -- is that correct? 2) On a user's click of a button, one of the actions in the button OnClick event is to set the selectedindex of the 2nd DDL to that of the 1st. I get a runtime error here that says that the given index is...
0
5963
by: sgtmarcjones | last post by:
How do I access a dropdownlist that is nested within a Formview ItemTemplate Gridview Template? I want to see a label (lgbTimeKeep ! TextValue of ddlName dropdownlist) instead of a dropdownlist in the FormView ItemTemplate Nested Gridview ddlName ItemTemplate. My label is named lgvTimeKeep and the dropdownlist name is ddlName. Thanks!
0
3742
by: andy | last post by:
Hi, I have a form uses several dropdownlists to narrow a set of criteria. ( This is in turn used to control what is shown on a gridview. ) With each, the user selects an entry and then the next dropdownlist uses that control's selected value to drive what it shows. They're all set to autopostback. Everything works fine except where one of the levels only has one entry. This seems to mess up the next level down and you see the wrong
0
9601
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10637
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10376
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10379
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10115
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9199
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6881
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
3861
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3014
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.