473,322 Members | 1,781 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,322 software developers and data experts.

Dropdownlist,DataTextField,DataValueField ?

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.SqlClient.SqlConnection()
Line 6:
Line 7: cnSQL.ConnectionString = "Password=88;Persist 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\samuellai\My
Documents\Header\NewFile.aspx Line: 7
Search.aspx
===========
<%@ Page Language="VB" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.SqlClient" %>
<script runat="server">
Dim cnSQL as New System.Data.SqlClient.SqlConnection()

cnSQL.ConnectionString = "Password=88;Persist 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.ExecuteReader

Do While dr.Read

End DO

dr.Close
GLDate = Nothing
dr = Nothing

</script>
<html>
<head>
</head>
<body>
<form runat="server">
<asp:DropDownList id="DropDownList1" runat="server"
OnSelectedIndexChanged="DropDownList1_SelectedInde xChanged" DataSource="<%#
SqlDataSourceControl2 %>" DataTextField="gl_date"
DataValueField="gl_date"></asp:DropDownList>
</form>
</body>
</html>
Please advise.

Many thanks.
Nov 19 '05 #1
1 2896
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********@hotmail.com> wrote in message
news:O5****************@tk2msftngp13.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.SqlClient.SqlConnection()
Line 6:
Line 7: cnSQL.ConnectionString = "Password=88;Persist 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\samuellai\My
Documents\Header\NewFile.aspx Line: 7
Search.aspx
===========
<%@ Page Language="VB" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.SqlClient" %>
<script runat="server">
Dim cnSQL as New System.Data.SqlClient.SqlConnection()

cnSQL.ConnectionString = "Password=88;Persist 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.ExecuteReader

Do While dr.Read

End DO

dr.Close
GLDate = Nothing
dr = Nothing

</script>
<html>
<head>
</head>
<body>
<form runat="server">
<asp:DropDownList id="DropDownList1" runat="server"
OnSelectedIndexChanged="DropDownList1_SelectedInde xChanged" DataSource="<%# SqlDataSourceControl2 %>" DataTextField="gl_date"
DataValueField="gl_date"></asp:DropDownList>
</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
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...
5
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 ...
5
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"...
8
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...
0
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...
11
by: Santosh | last post by:
Dear all , i am writting following code. if(Page.IsPostBack==false) { try { BindSectionDropDownlist();
1
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...
0
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...
0
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...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.