My DropDownList Won't Declare?
Need a little help! I am trying to insert ListItems values from a DropDownList into a database table. However in the code behind I am continuosly met with the error Name 'ddltest' is not declared. As you can see from the code below ddltest is an object with the ID ddltest. What am I doing wrong?
Protected Sub ddltest_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)Dim MyVar As String = ddltest.SelectedItem.Value
If MyVar = "" Then
ErrorMessage.Text = "Please select a test"
Else
'Insert selection into databaseDim oConnection As New SqlConnection
Dim oCommand As SqlCommand
Dim sConnString As String
Dim sSQL As String
sConnString = "Data Source=.SQLEXPRESS;AttachDbFilename=|DataDirectory|xxxxx.mdf;Integrated Security=True;User Instance=false"oConnection = New SqlConnection(sConnString)
sSQL = "INSERT INTO testDB(Myxxxx) Values (@Myxxxx)"
oConnection.Open()oCommand = New SqlCommand(sSQL, oConnection)oCommand.Parameters.Add(New SqlParameter("@Myxxxx", MyVar))
oCommand.ExecuteNonQuery()
oConnection.Close()
ErrorMessage.Text = "You selected " & MyVar & " and it has been added to the database."
End If
End Sub
<asp:TemplateField HeaderText="Test">
<EditItemTemplate>
<asp:DropDownList ID="ddltest" runat="server" AutoPostBack="True" OnSelectedIndexChanged="ddltest_SelectedIndexChanged" >
<asp:ListItem Selected="True" Value="" ><-- Please Select a test --></asp:ListItem><asp:ListItem Value="1">1</asp:ListItem>
<asp:ListItem Value="2">2</asp:ListItem>
<asp:ListItem Value="3">3</asp:ListItem>
<asp:ListItem Value="4">4</asp:ListItem>
<asp:ListItem Value="5" >5</asp:ListItem>
</asp:DropDownList>
</EditItemTemplate>
</asp:TemplateField>
View Complete Forum Thread with Replies
Related Forum Messages:
Fill Dropdownlist
hi, how can i fill dropdownlist through code not through visit.and i need to know which is fastest and easy way for web application throught this below query. cmd.Connection = conn conn.Open()Dim ds As New DataSet cmd.CommandText = "SELECT Emp_Name,Emp_ID FROM Employee " da.Fill(ds, "data") cmd.ExecuteNonQuery() conn.Close()
View Replies !
Not Inserting Dropdownlist
Hi folks, I'm in trouble getting an dropdownlist inserting its selected value into an .mdb I'll insert my datasource code. There is another dropdownlist in this formview working good. There is a datafield ID_Org_Einheit in the database to gather the value. Could you please look this over? Many thanks Rosi This is the dropdownlist <asp:DropDownList ID="DDL_Org_alle" runat="server" DataSourceID="SDS_Org_alle" DataTextField="OE_gegliedert" DataValueField="ID_org"> </asp:DropDownList> and the datasource <asp:SqlDataSource ID="SDS_insert_FB_log" runat="server" ConnectionString="<%$ ConnectionStrings:FahrtenbuchConnectionString %>" InsertCommand="INSERT INTO tab_Fahrtenbuch_log([Datum_Eintragung], [Fahrer], [ID_Org_Einheit], [pol_Kennzeichen], [ID_Einsatzzweck], [Strecke_von], [Strecke_bis], [Zeit_von], [Zeit_bis], [km_von], [km_bis]) VALUES (@Datum_Eintragung,@Fahrer,@ID_Org_Einheit,@pol_Kennzeichen,@ID_Einsatzzweck,@Strecke_von,@Strecke_bis,@Zeit_von,@Zeit_bis,@km_von,@km_bis)" ProviderName="<%$ ConnectionStrings:FahrtenbuchConnectionString.ProviderName %>" SelectCommand="SELECT Datum_Eintragung, Fahrer, ID_Einsatzzweck, Strecke_von, Strecke_bis, pol_Kennzeichen, ID_Org_Einheit, Zeit_von, Zeit_bis, Bemerkung, km_von, km_bis FROM tab_Fahrtenbuch_log"> <InsertParameters> <asp:FormParameter FormField="Datum_EintragungTextBox" Name="Datum_Eintragung"/> <asp:FormParameter FormField="FahrerEintragTextBox" Name="Fahrer"/> <asp:FormParameter FormField="DDL_Org_alle" DefaultValue="1" Name="ID_Org_Einheit"/> <asp:FormParameter FormField="polKennzTextBox" Name="pol_Kennzeichen"/> <asp:FormParameter FormField="DDL_Einsatzzweck" DefaultValue="1" Name="ID_Einsatzzweck" Direction="Input" Size="3" /><asp:FormParameter FormField="StartTextBox" Name="Strecke_von"/> <asp:FormParameter FormField="ZielTextBox" Name="Strecke_bis"/> <asp:FormParameter FormField="AbfahrtTextBox" Name="Zeit_von"/> <asp:FormParameter FormField="AnkunftTextBox" Name="Zeit_bis"/><asp:FormParameter FormField="kmFahrtBeginnTextBox" Name="km_von"/> <asp:FormParameter FormField="kmFahrtEndeTextBox" Name="km_bis"/> </InsertParameters></asp:SqlDataSource>
View Replies !
Can You Use Substring In ASP.NET On A DropDownList ?
I'm using the GridView to display some accounting infromation. I have a project where I have a 14 character control number. I would like to have a dropdown list to select the account classification of records to be displayed. The accounting classification is the first two characters of the control number. So the dropdown list needs to show unique first two characters and the GridView will be filtered on these two characters. I have been trying to use "substring" in the ASP.NET code; not even sure you can. Any suggestions on how to accomplish this would be greatly appreciated. See code below: <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" DataSourceID="SqlDataSource2" DataTextField="control_num" DataValueField="control_num"> </asp:DropDownList><asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:GPCRReportsConnectionString %>" SelectCommand="SELECT DISTINCT [substring(control_num,1,2)] FROM [Request]"></asp:SqlDataSource> ERROR: Invalid column name 'substring(control_num,1,2)'.
View Replies !
Sqldatasource And Dropdownlist
Hi, I have sqldatasource that i set up in VS2005. i have a dropdownlist using this source. Data is added to the db from a different app and i want this dropdownlist to use the latest data on a page refresh. However i can not refresh the sqldatasource - the dropdownlist does not show the latest additions to the db - i hae to rebuild to see them. i tried turnning 'enable caching' and 'enable viewstate' to false but no luck. How is this done. Thanks.
View Replies !
Gridview And DropDownList
Hello:I have add a DropDownList to my GridView and binded the dropdownlist to a field from a select statement in the SQLDataSource. I have EnabledEditing for my GridView. The GridView is populated with information from the select statement. Some of the information returned from the select statement is null. The field where the dropdownlist is binded it is null in some cases and does not have a value that is in the dropdownlist so I get and error when I attempt to do an update. 'DropDownList1' has a SelectedValue which is invalid because it does not exist in the list of items.Parameter name: value Is there a way to get around this besides initializing all the columns in the table that are going to be binded to a dropdownlist to a value in the dropdownlist?
View Replies !
Populating Dropdownlist
I've got the following code and it's not really what I want. With the below code I can select in a dropdownlist a value and in the other dropdownlist the correspondending value will be selected. But when I select a value the second dropdownlist won't be filled with all the data in the database. It is filled only with the correspondending value and not with the rest of the value. When someone changes his mind and want to select a value in the dropdownlist it can't be done. Any ideas??Default.aspx:<body> <form id="form1" runat="server"> <div> <asp:Label ID="Label1" runat="server" Text="Botanische Naam: "> </asp:Label> <asp:DropDownList ID="DDL1" AutoPostBack="True" runat="server" OnSelectedIndexChanged="ChangeBotanicName" DataSourceID="SqlDataSource1" DataTextField="Botanische_Naam" DataValueField="Botanische_Naam"> </asp:DropDownList> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:BonsaiDataBaseConnectionString %>" SelectCommand="SELECT [Botanische Naam] AS Botanische_Naam FROM [BonsaiSoorten]"> </asp:SqlDataSource> <asp:sqldatasource id="SqlDataSource2" runat="server" connectionstring="<%$ ConnectionStrings:BonsaiDataBaseConnectionString%>" selectcommand="SELECT [Nederlandse Naam] AS Nederlandse_Naam FROM [BonsaiSoorten]WHERE [Botanische Naam] = @Title1"> <selectparameters> <asp:controlparameter name="Title1" controlid="DDL1" propertyname="SelectedValue" /> </selectparameters> </asp:sqldatasource> <asp:Label ID="Label2" runat="server">Nederlandse Naam:</asp:Label> <asp:DropDownList ID="DDL2" AutoPostBack="True" runat="server" OnSelectedIndexChanged="ChangeDutchName" DataSourceID="SqlDataSource3" DataTextField="Nederlandse_Naam" DataValueField="Nederlandse_Naam"> </asp:DropDownList> <asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:BonsaiDataBaseConnectionString %>" SelectCommand="SELECT [Nederlandse Naam] AS Nederlandse_Naam FROM [BonsaiSoorten]"> </asp:SqlDataSource> <asp:sqldatasource id="SqlDataSource4" runat="server" connectionstring="<%$ ConnectionStrings:BonsaiDataBaseConnectionString%>" selectcommand="SELECT [Botanische Naam] AS Botanische_Naam FROM [BonsaiSoorten]WHERE [Nederlandse Naam] = @Title2"> <selectparameters> <asp:controlparameter name="Title2" controlid="DDL2" propertyname="SelectedValue" /> </selectparameters> </asp:sqldatasource> </div> </form></body>Default.aspx.vb:Partial Class _Default Inherits System.Web.UI.Page Sub ChangeBotanicName(ByVal Sender As Object, ByVal e As System.EventArgs) DDL2.DataSourceID = "SqlDataSource2" End Sub Sub ChangeDutchName(ByVal Sender As Object, ByVal e As System.EventArgs) DDL1.DataSourceID = "SqlDataSource4" End SubEnd Class P.S. I posted this before but can't find it anymore so here it is again
View Replies !
Inserting DropDownList Value Into DB
Hi... im trying to insert whatever value a user selects from a drop down list box into a database. So I have already stated that there are 5 different options (eg. 1,2,3,4,5) so I want it that when someone selects '2' and then clicks a button it inserts '2' into a db... I tried the following (DDL is the id of the drop down list box) : Dim myCommand As SqlCommandDim objUsers As SqlTransactionDim strnumber As String = DDL.SelectedValueconnstring = System.Configuration.ConfigurationManager.AppSettings("ConnectionString")conUsers = New SqlConnection(connstring)conUsers.Open()objUsers = conUsers.BeginTransaction "INSERT INTO tblsomething (number) VALUES (strnumber)" myCommand = New SqlCommand(strSQL, conUsers)myCommand.Transaction = objUsersmyCommand.ExecuteNonQuery()objUsers.Commit()conUsers.Close() - Anyway suffice to say that this isnt working sssooooo...... help. Please
View Replies !
Dropdownlist -default Value!!
hi , need your help please I have got a dropdownlist which is getting it's items and values from the table with in SQL server , everything works fine. I just want to be able to select default item , so when the page is loaded the dropdown list default will be that selected item. as an exmple if the drop downlist items and values are as follow item ----> value --------------------- city -----> 1 tokyo -----> 2 london ------>3 these info is imported from the database and I want by default tokyo to be selected many thanks M ---------------------------------------- here is my code: Dim sqlConnection As SqlConnection Dim sqlDataAdapter As SqlDataAdapter Dim sqlCommand As SqlCommand Dim dataSet As DataSet Dim dataTable As DataTable sqlConnection = New SqlConnection("user id=sa;password=testfirm;database=ken_live;server=csfirm03") 'pass the stored proc name and SqlConnection sqlCommand = New SqlCommand("Select * From _aci",sqlConnection) 'instantiate SqlAdapter and DataSet sqlDataAdapter = New SqlDataAdapter(sqlCommand) dataSet = New DataSet() 'populate the DataSet sqlDataAdapter.Fill(dataSet, "AA") 'apply sort to the DefaultView to sort by CompanyName dataSet.Tables(0).DefaultView.Sort = "bsheet" city.DataSource = dataSet.Tables("AA").DefaultView city.DataTextField ="bsheet" ' what to display city.DataValueField ="bsheet" ' what to set as value city.DataBind()
View Replies !
Clarification For 'WHERE' Statement In A Dropdownlist
My goal is to populate a dropdownlist with only with users that are "Techs". I am using the membership database that you ccan set up through VWD. I added this column to the aspnet_Users table: IsTech as bit datatype. I thought I had the right SQL statement but apparently not, because I get an Invalid column name 'True'.Here is my statement: <asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:HRIServiceConnectionString1 %>" SelectCommand="SELECT [UserID], [FirstName]+ ' ' + [LastName] AS techid FROM [aspnet_Users] WHERE [isTech] = True ORDER BY [LastName], [FirstName]"> </asp:SqlDataSource>
View Replies !
Handle Null Value For DropDownList?
Using asp.net 2.0 and visual studio 2005. The question is regarding the following ER diagram: I've made Firstname, lastname, buildingID and RoomNum all required fields. I've got a modified GridView that displays all of the table Faculty columns. It's been modified so the BuildingID and DepID are resolved to their actual field names and displayed in a DropDownList. In the dropdown list I used for inserting (a seperate DetailsView control), I manually inserted an item into the Department dropdownlist which had the text "-- Select a Department --" with a value of -1. MS SQL didn't like that -1 value so I wrote the following code to fix it: protected void dsFaculty_Inserting(object sender, SqlDataSourceCommandEventArgs e) { if (e.Command.Parameters["@DeptID"].Value.ToString() == "-1") { e.Command.Parameters["@DeptID"].Value = null; } } That means of course DeptID is null, which is ok. The problem arises is when I try to edit that row in the GridView. I get the an error 'ddlDepartment' has a SelectedValue which is invalid because it does not exist in the list of items.Parameter name: valueIdeally, I'd like to make the dropdown list in the GridView show "-- None --" for the DeptID if it comes across a null value. I already tried playing around with the Command.Parameters in the dsFaculty_Selected function, but it didn't work. Ideas?
View Replies !
DropDownList Inside CreateUserWizard
I am using the createuserwizard, and have set up my own profile table which hold first name, last etc. In my CreateUserWizard, the field for Vendor is a dropdownlist that is to be populated from a list in a database. I set up the form without the createuserwizard, and everything went skippy, but when I placed it into the wizard, I now cannot access the control of the dropdownlist. I have tried doing.. Using SqlConnection As New SqlConnection(WebConfigurationManager.ConnectionStrings("Personal").ConnectionString)Dim VendorID As DropDownListVendorID = CType(CreateUserWizard1.FindControl("VendorName"), DropDownList) Dim MyReader As SqlDataReaderDim sel As String = String.Format("SELECT VendorID, Name FROM Vendors")Dim MyCommand As SqlCommandMyCommand = New SqlCommandMyCommand.CommandText = selMyCommand.CommandType = CommandType.TextMyCommand.Connection = SqlConnectionMyCommand.Connection.Open()MyReader = MyCommand.ExecuteReader(CommandBehavior.CloseConnection)But when I go to databind, it says:Object reference not set to an instance of an object. VendorID.DataSource = MyReaderLine 30: VendorID.DataValueField = "VendorID"Line 31: VendorID.DataTextField = "Name"
View Replies !
Dropdownlist Database Search
Hi all. I have a huge problem that ive been sitting with for awhile. I have a web page with 4 dropdownlist boxes on it Gender: Race: Field: Location: Now a user can search a SQL db from selecting values from these 4 dropdownlist boxes which are equal to values in the db obviously. when they have done that and pressed submit a Gridview is populated with the people corresponding details and the user is able to view each row seperately. Now the problem i am having is that when i havent used all 4 selections for eg Gender: null (no value selected) Race: Black Field: Accounting Location: Los Angeles then no information is returned from the db in the gridview. im using a sqldatasource to populate the gridview and here is the query string that i am using : Code: sql SELECT [title], [gender], [initials], [name], [surname], [birthdate], [postaladdress], [suburb], [city], [zipcode], [criminalrecord], [drivers], [maritalstatus], [dependants], [citizenship], [province], [contactref], [hometel], [cell], [jobtitle], [relocate], [emmigrate], [email], [worktel], [enddate], [startdate], [FIELD], [education], [company], [positionheld], [jobdescription], [contactperson], [contacttel], [startdate2], [contactperson3], [jobdescription3], [positionheld3], [company3], [enddate3], [startdate3], [contacttel3], [other] FROM [cvinformation] WHERE (([race] = CASE WHEN @race IS NOT NULL THEN @race ELSE [race] END) AND ([province] = CASE WHEN @province IS NOT NULL THEN @province ELSE [province] END) AND ([education] = CASE WHEN @education IS NOT NULL THEN @education ELSE [education] END)) what i want to do is whether the user doesnt choose any selection and leaves the choice null that ALL the information in the table of the db be shown and even if they only choose 2 values and leave the others null then it still brings back the information from the criteria chosen.. Is this possible.?
View Replies !
How To Make A Dropdownlist Empty
I have a listbox that lists countries....and if you choose a country, another listbox show cities in that country (fetched from a sql database)....And if you then chose a city in the second listbox, a dropdownlist will show restaurants in the city....(also fetched from a sql-database)... Ok...I hope you understand...now to the problem....: If you first chose a country, a city and a restaurant but then want to chose another country in the first listbox, the dropdownlist for the restaurants is still there filled with restaurants for the first country...I dont know how to "remove" the restaurants so that the dropdownlist is blank if someone switch country.... I think I need to do something in countryListbox_SelectedIndexChange....but I dont know what to write there.... I know that I can make the dropdownlist invisible by entering the following code: sub countryListbox_SelectedIndexChange dropdownlistRestaurants.visible = false End sub But I want it to be visible all the time! Do you know what I could do?
View Replies !
How To Create Store Procedure To Use With Dropdownlist
Dear all, i want to create a storeprocedure that may acept value such as 0,1, 1a, 2, 2a etc.. from a dropDownList. But i always get an error. below is sample of my SQL1 DECLARE @val varchar(5) 2 DECLARE @sql varchar(4000) 3 4 SET @val = '1a' 5 SET @sql = 'select * FROM [dbo].[vwFormNAllAnswers]' 6 7 IF @val NOT LIKE '0' 8 SET @sql = @sql + 'WHERE QuestionCode LIKE '+ @val 9 10 EXEC(@sql)
View Replies !
Conditional Population Of A DropDownList Control
I have two DropDownList controls, ddlGroup and ddlLocation. The contents of ddlLocation will be determined by the selection of ddlGroup. A better explanation is as follows: ddlGroup = ADVANCED DEVELOPMENT DESIGN HEAD TEST INK R&D JETTING PROCESS RELIABILITY The SQL query that shows my logic is: IF @Group = 'ADVANCED DEVELOPMENT' SELECT Location FROM tblLocations WHERE Location like 'AD%'ELSE IF @Group = 'DESIGN' SELECT Location FROM tblLocations WHERE Location like 'DE%'ELSE IF @Group = 'HEAD TEST' SELECT Location FROM tblLocations WHERE Location like 'HT%'ELSE IF @Group = 'INK R&D' SELECT Location FROM tblLocations WHERE Location like 'INK%'ELSE IF @Group = 'JETTING' SELECT Location FROM tblLocations WHERE Location like 'JT%'ELSE IF @Group = 'PROCESS' SELECT Location FROM tblLocations WHERE Location like 'PR%'ELSE IF @Group = 'RELIABILITY' SELECT Location FROM tblLocations WHERE Location like 'RL%' I need to define the content of ddlLocation after a selection is made in ddlGroup; how can I accomplish this using Visual Web Developer 2008 Express Edition?
View Replies !
Stored Procedure For Getting Data Into Dropdownlist
Hi iam working with two dropdownlists,one gets the data dynamically when the pageload.later after selecting particular item in the dropdownlist1 i must get data to the dropdownlist2 depending on 1. For example: Dropdownlist1 is for industry and 2 is for company. when i select particual industry in ddl1 i must get companies based on this industry in ddl2.Both the Industry name and company name are maintained in two different tables industry and company with common field ID.please help me with a stored procedure to sort out this problem...
View Replies !
Select Query Issue (dropdownlist Too)
Hi All, In my scenario, I am using one sqldatasource with two columns 1. Code_ID 2. Code + ' - ' + CompanyName As Display Now I bind ddlCompany.datatextfield = Display ddlCompany.datavaluefield = Code_ID But the problem is when my CompanyName is NULL value, it does not show my Code too....for example Code = 1098 CompanyName = NULL Sql query returns me NULL for this combination....and so my dropdownlist shows blank......can anyone show me the alternative. Thanking in advance,
View Replies !
Is It Possible To Dispaly All Columns For A Record In A Dropdownlist
Say a record has four columns in { Emp#, firstName, secondName, thirdName, spouseName }. Now if you configure a sql datasource for a dropdownlist to return all columns, only Emp# will be displayed in the dropdownlist, the other columns wont be listed. Is there a way to list the values of all columns in the dropdownlist using the sql datasource or in ADO.net code. Thanks.
View Replies !
Dropdownlist With Stored Procedure Problem
Hi Everyone,I am trying to load the data into the dropdownlist using stored procedure. But when I run the code, the dropdownlist is empty. The code is shown below. Please help! Thanks. public DataSet getProvince() { DataSet ds = new DataSet(); SqlParameter myParam; string conString; SqlConnection myConnection; conString = ConfigurationManager.AppSettings["connectionString"]; myConnection = new SqlConnection(conString); SqlCommand cmd = new SqlCommand("stored_procedure_GetProvinces", myConnection); SqlDataAdapter adpt = new SqlDataAdapter(cmd); try { cmd.CommandType = CommandType.StoredProcedure; myParam = cmd.Parameters.Add("@province_key", SqlDbType.Int); myParam.Direction = ParameterDirection.Output; myParam = cmd.Parameters.Add("@province_name", SqlDbType.NVarChar, 200); myParam.Direction = ParameterDirection.Output; adpt.Fill(ds, "Provinces"); myConnection.Close(); } catch (SqlException ex) { Response.Write("Error: " + ex.Message); } return ds; }---------------------------------- create procedure stored_procedure_GetProvinces ( @province_key int output, @province_name nvarchar (200) output ) As Select @province_key=province_key, @province_name=province_name From province GO ------------------------- <asp:DropDownList id="Dropdownlist_Province" DataValueField="province_key" DataTextField="province_name" DataSource='<%# getProvince() %>' Runat="server" > </asp:DropDownList> -------------------------------- if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[province]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) drop table [dbo].[province]GOCREATE TABLE province (province_key int IDENTITY PRIMARY KEY,province_name nvarchar (200) NULL)GOINSERT INTO province(province_name) VALUES ('- Select -');GOINSERT INTO province (province_name) VALUES ('Ontario');GOINSERT INTO province (province_name) VALUES ('Alberta');GOINSERT INTO province (province_name) VALUES ('British Columbia');GOINSERT INTO province (province_name) VALUES ('Manitoba');GOINSERT INTO province(province_name) VALUES ('New Brunswick');GOINSERT INTO province (province_name) VALUES ('Newfoundland');GOINSERT INTO province (province_name) VALUES ('Northwest Territories');GOINSERT INTO province (province_name) VALUES ('Nova Scotia');GOINSERT INTO province (province_name) VALUES ('Nunavut');GOINSERT INTO province (province_name) VALUES ('Prince Edward Island');GOINSERT INTO province (province_name) VALUES ('Quebec');GOINSERT INTO province (province_name) VALUES ('Saskatchewan');GOINSERT INTO province (province_name) VALUES ('Yukon Territory');GO
View Replies !
Search For Database Using Textbox And Dropdownlist
hello..i need your help to provide me the idea and code how to view the data from database based on search criteria from user's input?the user's may fill up textbox and choose a criteria from dropdownlist...i am so no idea how to code it since i am fairly new in asp.net
View Replies !
Using DropDownList And TextBox To Filter Results...
Hey all, I've been searching for a while and haven't really found an answer for what I'm trying to do. Here it all is and someone can tell me if I'm going in the wrong direction to solve this. I have a textbox set to a parameter of "SearchString" and a DropDownList with the SelectedValue paramter of "FilterValue". The parameters work, I've tested that. So here is the problem. I am trying to use the "FilterValue" to pick the field that the "SearchString" searches with a LIKE statement (e.g. SELECT * FROM dbo.Units WHERE (@FilterValue LIKE '%'+@SearchString+'%')) This, I've found out, doesn't work. I have this setup with a DataLayer.vb in my App_Code directory handling the SQL calls, while the normal CodeBehind is in the typical "Default.vb" page. I will post code later as I don't have access to it right now, but if anyone can explain how a filter like this would work I would appreciate it! Thanks, -Matthew
View Replies !
Database && Dropdownlist && Selecte Statement
Hi i have a table called table1 in my database. that table contains 4 columns (taID -primery key, headline , description, catID) the catID is a numeric value that i have in another table (catTable), in this table (catTable) i have 2 columns (catID and catName). the content of this table looks like this: catID catName 1 Volvo 2 GM 3 Toyota 4 F16 5 Blackbird 6 747 in my aspx page i have a gridview that displays the content of these coulmns depending on a dropdownlist that is bounded to the catID. e.g if the value of the selected item in the dropdownlist is 1 the gridview is filters the (table1) to show only the content that have the catID = 1. the items in my dropdownlist is bounded to the category table (catTable) the dropdownlist looks like this: ---CARS--- Volvo GM Toyota ---AEROPLANES--- F16 Blackbird 747 as you can see the headlines (CARS and AEROPLANES) are not in the database i have added them using the insert method, they do not represent any category , they are just headlines in the dropdownlist. so what i want to do is when I select a headline from the dropwdownlist e.g CARS i want the gridview to show me all the rows in my table1 that have the catID = 1 and 2 and 3 and the same if i select AEROPLANES i want the gridview to show me the rows that have the catID=4,5,6. i have tried to write a sql selete statement but with no success. thank you
View Replies !
Choose Default Value From DropDownList And SqlDataSource
Hello everyone I'm really new to Data Presentation Controls and I already hate them couse I think they are way too complicated. Becouse of that i have already met wall many times. My last one sounds like this. I'm triing to put a default value from, lets say SqlDataSource1 in a DropDownList that is created by SqlDataSource2. I know how to get value from SqlDataSource1 but I don't know how to use exactly that value as my default value in DropDownList. Two more question. 1. Is it possible to have two different select statements in a SqlDataSource? 2. A SqlDataSource may contain an insert statement, select statement, update and delete. If I bind this SqlDataSource to a control how can I specify which of those statements will be used? Thanks in advance
View Replies !
Proper Sorting Of Months In DropdownList
I'm having an issue getting the data how I want it from SQL to then populate my dropdownlist. I have a table called SALES_BUDGR_TBL that contains alot of columns but the ones I'm focusing on are SRCURM (Month) and SRACYR (Year). What I need to do is populate a dropdownlist and show the current month first and then work backwards. The data in the dabase goes back 14 months. I created a reference table called MonthOrder that has 3 columns, MonthID, MonthName and MonthAbrv. I did this so I have a way of saying which month belongs where when sorted. Here is the select statement I currently have. I'm joining the tables and then I want to Order by the MonthID, but I would also like it to show the 2006 records first, then goto 2005, starting with December and going down of course. Is there anyway to do this? My Select and Results are below... SELECT DISTINCT SB.SRCURM, SB.SRACYR, MO.MonthID, MO.MonthName FROM SALES_BUDGR_TBL SBINNER JOIN MonthOrder MO ON SB.SRCURM = MO.MonthAbrvORDER BY MO.MonthID DESC DEC 2005 12 DecemberNOV 2005 11 NovemberOCT 2005 10 OctoberSEP 2005 09 SeptemberAUG 2005 08 AugustJUL 2005 07 JulyJUN 2005 06 JuneMAY 2005 05 MayAPR 2005 04 AprilAPR 2006 04 AprilMAR 2006 03 MarchFEB 2005 02 FebuaryFEB 2006 02 FebuaryJAN 2006 01 January If I say only get 2006 records it works but I need a better way to do this.
View Replies !
DropdownLIst Box Question, Stored Procedure
Hi All, I have a dropdownlist box with values (All, Paris, London, New York) -- Cities Another dropdwonlist box with values (All, Bank of America, City Bank, CIBC) -- Banks And have a stored procedure that populates the info: CREATE Procedure Search( @City nvarchar(50), @Bank nvarchar(50))AS SELECT * FROM TableA WHERE city = @city AND bank= @bank GO If user selects a value anything other than "All" in both dropdownbox, everything is OK. My question is, if user selects "All" in any of these dropdown combobox, how can I seach for all Cities or Banks. SQL needs to run as a stored procedure. If it was on client end, it would be alot easier. Any ideas? Thanks for your help.
View Replies !
Multi-select Dropdownlist With Checkboxes
When creating a windows forms report (rdl), multi-value parameters are rendered with a nice drop down list with check boxes...including a (Select All) item. When you run this via a report server and render the report for the web, the multi-value selection shows up nicely. Can I create a similar web form dropdownlist so I can duplicate the functionality with an RDLC report? Jim
View Replies !
Caching A Dropdownlist Programmatically With Sqldatasource Problems...
Hi I have added an Optiongroup option to my dropdownlist. The code below works fine so that the Dropdownlist with the Optiongroup displays like this:CATEGORY 1Item 1Item 2CATEGORY 2Item 3Item 4 etc. However the Dropdownlist does not cache the results using my code below - this code programmatically uses a Sqldatasource so that I can use the Enablecaching feature. I can get dropdownlists to cache without the Optiongroup feature but not with it... Any help would be appreciated. Thanks in advance.Kevin ============================================DROPDOWNLIST USERCONTROL WITH OPTIONGROUP <%@ Control Language="VB" ClassName="categories_dropdown" %><%@Import Namespace="System.Data" %><%@Import Namespace="System.Data.Common" %><%@Import Namespace="System.Data.SqlClient" %><%@Import Namespace="System.Web.Configuration" %><%@Import Namespace="CraigBlog" %><%@Import Namespace="Kfunctions" %><script runat="server"> Dim strConString As String Dim strUpdate As String Dim cmdUpdate As SqlCommand Dim intSiteID As Integer Dim connTC As New SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings("connectionString").ConnectionString) Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) If Not IsPostBack Then Dim cmdCategory As SqlCommand Dim dtrCategory As SqlDataReader Dim liItem As ListItem Dim intCategoryID As Integer 'Retrieve category ID from querystring Try intCategoryID = Int32.Parse(Request.QueryString("CategoryID")) Catch 'do nothing End Try cmdCategory = New SqlCommand(SqlDataSource1.SelectCommand, connTC) SqlDataSource1.EnableCaching = "true" SqlDataSource1.CacheDuration = "300" connTC.Open() 'Populate dropdown list Category with sub category headings dtrCategory = cmdCategory.ExecuteReader() While dtrCategory.Read() liItem = New ListItem() liItem.Value = (Server.HtmlDecode(adminconstantclasses.DealWithNulls(dtrCategory("CategoryID"), ""))) liItem.Text = (Server.HtmlDecode(adminconstantclasses.DealWithNulls(dtrCategory("Category"), ""))) liItem.Attributes("OptionGroup") = UCase(Server.HtmlDecode(adminconstantclasses.DealWithNulls(dtrCategory("fldsubcategoryname"), ""))) dropCategory.Items.Add(liItem) End While dtrCategory.Close() connTC.Close() 'inserts extra option in dropdown list as first item - shows text and default value dropCategory.Items.Insert(0, New ListItem("*** Choose teams or categories ***", "0")) End If End Sub 'choose category from dropdown selection Sub eventRedirect(ByVal Src As Object, ByVal Args As EventArgs) Dim strDropDown01SelectedItem As String = Trim(dropCategory.SelectedItem.Value) 'see if it's the first item in the dropdown ie 'Choose'. If strDropDown01SelectedItem = "0" Then Response.Redirect("~/directory/default.aspx?CategoryID=" & strDropDown01SelectedItem) Else Response.Redirect("~/directory/viewsections.aspx?CategoryID=" & strDropDown01SelectedItem) End If End Sub </script><asp:DropDownList OnSelectedIndexChanged="eventRedirect" AutoPostBack="true" ID="dropCategory" runat="server" /><asp:SqlDataSource ID="SqlDataSource1" ProviderName="System.Data.SqlClient" runat="server" ConnectionString="<%$ ConnectionStrings:connectionString %>" SelectCommand="Select CategoryID,Category,fldsubcategoryname,fldDisplayOrder FROM Category LEFT OUTER JOIN tblSubCategory ON tblsubcategory.fldsubcategoryID=Category.fldsubcategoryID ORDER BY fldDisplayOrder,Category ASC"></asp:SqlDataSource> ===========================================OPTIONGROUP CLASS TO ADD OPTIONGROUP FEATURE TO DROPDOWNLIST Imports SystemImports System.DataImports System.ConfigurationImports System.WebImports System.Web.SecurityImports System.Web.UIImports System.Web.UI.WebControlsImports System.Web.UI.WebControls.WebPartsImports System.Web.UI.HtmlControlsImports System.CollectionsImports System.Collections.GenericPublic Class DropDownListAdapter Inherits System.Web.UI.WebControls.Adapters.WebControlAdapter Private Const m_optionGroupAttribute As String = "OptionGroup" Private Const m_tagOptionGroup As String = "optgroup" Private Const m_attributeLabel As String = "label" Private m_viewstates As Object() Protected Overrides Sub RenderContents(ByVal writer As HtmlTextWriter) If (Not Page Is Nothing) Then Dim l_list As DropDownList = CType(Me.Control, DropDownList) Dim l_currentOptionGroup As String Dim l_renderedOptionGroups As New ArrayList() For Each l_item As ListItem In l_list.Items Page.ClientScript.RegisterForEventValidation(l_list.UniqueID, l_item.Value) If l_item.Attributes(m_optionGroupAttribute) Is Nothing Then RenderListItem(l_item, writer) Else l_currentOptionGroup = l_item.Attributes(m_optionGroupAttribute) If (l_renderedOptionGroups.Contains(l_currentOptionGroup)) Then RenderListItem(l_item, writer) Else If (l_renderedOptionGroups.Count > 0) Then RenderOptionGroupEndTag(writer) End If RenderOptionGroupBeginTag(l_currentOptionGroup, writer) l_renderedOptionGroups.Add(l_currentOptionGroup) RenderListItem(l_item, writer) End If End If Next If (l_renderedOptionGroups.Count > 0) Then RenderOptionGroupEndTag(writer) End If Else MyBase.RenderContents(writer) End If End Sub Private Sub RenderOptionGroupBeginTag(ByVal name As String, ByVal writer As HtmlTextWriter) writer.AddAttribute(m_attributeLabel, name) writer.RenderBeginTag(m_tagOptionGroup) End Sub Private Sub RenderOptionGroupEndTag(ByVal writer As HtmlTextWriter) writer.RenderEndTag() End Sub Private Sub RenderListItem(ByVal item As ListItem, ByVal writer As HtmlTextWriter) For Each key As String In item.Attributes.Keys If (key <> m_optionGroupAttribute) Then writer.AddAttribute(key, item.Attributes(key)) End If Next writer.AddAttribute(HtmlTextWriterAttribute.Value, item.Value, True) If (item.Selected) Then writer.AddAttribute(HtmlTextWriterAttribute.Selected, "selected") End If writer.RenderBeginTag(HtmlTextWriterTag.Option) writer.WriteEncodedText(item.Text) writer.RenderEndTag() End Sub Protected Overrides Function SaveAdapterViewState() As Object If (Not Page Is Nothing) Then Dim l_list As DropDownList = CType(Control, DropDownList) Dim l_viewState(l_list.Items.Count + 1) As Object Dim i As Integer = 0 For Each item As ListItem In l_list.Items l_viewState(i) = item.Attributes(m_optionGroupAttribute) i += 1 Next l_viewState(i) = MyBase.SaveAdapterViewState() Return l_viewState Else Return MyBase.SaveAdapterControlState() End If End Function Protected Overrides Sub LoadAdapterViewState(ByVal state As Object) If (Not Page Is Nothing) Then m_viewstates = CType(state, Object()) MyBase.LoadAdapterViewState(m_viewstates(m_viewstates.Length - 1)) Else MyBase.LoadAdapterViewState(state) End If End Sub Protected Overrides Sub OnPreRender(ByVal e As System.EventArgs) If (Not Page Is Nothing) Then If (Not m_viewstates Is Nothing AndAlso m_viewstates.Length > 1) Then Dim l_list As DropDownList = CType(Control, DropDownList) If (Page.EnableEventValidation) Then If (m_viewstates.Length <> l_list.Items.Count + 1) Then Throw New ViewStateException() End If End If Dim l_max As Integer = m_viewstates.Length If (l_list.Items.Count < l_max) Then l_max = l_list.Items.Count End If For i As Integer = 0 To l_max - 1 l_list.Items(i).Attributes(m_optionGroupAttribute) = CStr(m_viewstates(i)) Next End If End If MyBase.OnPreRender(e) End SubEnd Class
View Replies !
Joining Two Dropdown Lists To Create Third Dropdownlist
How do i add two values of Dropdownlist 1 and 2 to create No.3 Is there an easy way through Visual Studio to do this than Realms of code that i have been reading online, Surely, there is some command that is like Select Distinct Name from Clients WHERE city=@city + country=@country Or is it not this easy?
View Replies !
Problem Modifying Sqldatasource For Dropdownlist Control
i use asp.net 2.0 and c# initially the dropdownlist control is bound to the queryA ("select * from tableA".) for sqldatasource1 now in a button click event, i want to change the query to queryB ("select * from tableA where id = @id".) in the code below, i can change the SELECT query of sqldatasource1 from queryA to queryB, but how can i give value to the parameter? please help protected void Button1_Click(object sender, EventArgs e) { sqldatasource1.SelectCommand = queryB }
View Replies !
Dropdownlist: Database Connections Problems At EditItemTemplate
Hello, I'm attempting to generate a dropdownlist by binding it to a database table. My screen has a view of the records plus a footer for inserting new records. I want to populate a drop down list of items from the database on both FooterTemplate and EditItemTemplate. I can successfully create the list on FooterTemplate (the insert new record fields). Here, I have no problems with my database connections. On page load, if I hit 'Edit', it gives me this error: There is already an open DataReader associated with this Connection which must be closed first. I tried closing the datareader and I get an error: Invalid attempt to Read when reader is closed. Here's the snippet of code: Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'Put user code to initialize the page here LoadDataFromDB() If Not IsPostBack Then DataBindGrid() End If End Sub Sub LoadDataFromDB() Dim strSQLStmnt As String Dim cmdDefaults As SqlCommand ' Create new command object passing it our SQL query ' and telling it which connection to use. strSQLStmnt = "SELECT tblTemplates.TemplateID, tblTemplates.Description, " _ & "tblTemplates.Tuition, tblTemplates.Books, tblTemplates.TrainingTable, tblTemplates.Housing, " _ & "tblResidency.ResidencyType, tblCategory.Type, tblCategory.Description AS CategoryDesc, " _ & "tblScholarship.ScholarshipType FROM tblTemplates INNER JOIN tblResidency ON tblTemplates.ResidencyID = " _ & "tblResidency.ResidencyID INNER JOIN tblScholarship ON tblTemplates.ScholarshipID = tblScholarship.ScholarshipID " _ & "INNER JOIN tblCategory ON tblTemplates.CategoryID = tblCategory.CategoryID" cmdDefaults = New SqlCommand(strSQLStmnt, conDefaults) ' Open the connection, execute the command, and close the connection. conDefaults.Open() rdrDefaults = cmdDefaults.ExecuteReader(System.Data.CommandBehavior.CloseConnection) DefaultsDataGrid.ShowFooter = True End Sub Sub DataBindGrid() DefaultsDataGrid.DataSource = rdrDefaults DefaultsDataGrid.DataBind() End Sub Function BindResidency() As DataSet 'Populate the ddlDataSet Const strSQLDDL As String = _ "SELECT Distinct ResidencyID, ResidencyType FROM tblResidency" Dim myDataAdapter As SqlDataAdapter = New _ SqlDataAdapter(strSQLDDL, conDefaults) myDataAdapter.Fill(ddlDataSet) Return ddlDataSet End Function And the asp.net: <asp:TemplateColumn HeaderText="Residency"> <ItemTemplate> <%# Container.DataItem("ResidencyType") %> </ItemTemplate> <FooterTemplate> <asp:DropDownList id="add_residency" runat="server" Width="178px" DataSource="<%# BindResidency() %>" DataTextField="ResidencyType" DataValueField="ResidencyID"> </asp:DropDownList> </FooterTemplate> <EditItemTemplate> <asp:DropDownList id="edit_residency" runat="server" Width="178px" DataSource="<%# BindResidency() %>" DataTextField="ResidencyType" DataValueField="ResidencyID"> </asp:DropDownList> </EditItemTemplate> </asp:TemplateColumn> Any help would be appreciated! Thanks, Curtis
View Replies !
Building Dynamic Query Based On Dropdownlist Contents
Thanks in advance for taking the tiemt o read this post: I am workingon an application in vb.net 2008 and I have 5 drop down lists on my page. I have code that worked in .net 2005 for my databind but would like to use new features in 08 to do this same thing. Here is my 05 code how would I do this same things in 08? Dim db As New DataIDataContext Dim GlobalSQLstr As String GlobalSQLstr = "select Orig_City, ecckt, typeflag, StrippedEcckt, CleanEcckt, ManualEcckt, Switch, Vendor, FP_ID, order_class, Line_type, id from goode2 where 1=1" If (ddlOrigCity.SelectedValue <> "") Then GlobalSQLstr &= "and Orig_City = '" & ddlOrigCity.SelectedValue & "'" End If If (ddlSwitch.SelectedValue <> "") Then GlobalSQLstr &= "and switch = '" & ddlSwitch.SelectedValue & "'" End If If (ddlType.SelectedValue <> "") Then GlobalSQLstr &= "and Order_Class = '" & ddlType.SelectedValue & "'" End If If (ddlFormatType.SelectedValue <> "9") Then GlobalSQLstr &= "and typeflag = '" & ddlFormatType.SelectedValue & "'" End If If (ddlVendor.SelectedValue <> "") Then GlobalSQLstr &= "and Vendor = '" & ddlVendor.SelectedValue & "'" End IfDim AllSearch = From A In db.GoodEcckts2s If (ddlErrorType.SelectedValue <> "0") Then GlobalSQLstr &= "and ErrorType = '" & ddlErrorType.SelectedValue & "'" End IfDim cmd As New SqlClient.SqlCommand Dim rdr As SqlClient.SqlDataReaderWith cmd.Connection = New SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings("ConnectionString1").ConnectionString) .CommandType = Data.CommandType.Text .CommandText = GlobalSQLstr .Connection.Open() rdr = .ExecuteReaderMe.gvResults.DataSource = rdrMe.gvResults.DataBind() .Connection.Close() .Dispose()End With
View Replies !
Problem In Saving Page Contents I.e; Textbox And Dropdownlist Values Please Help
Hi all,please have a look of code i am unable to perform save operation onthe asp.net web page.I ahve written a stored procedure. the same code works if all aretextboxes, but some of textbox replaced with dropdownlist box thenthis save operation doesn't occurs. please let me know where is themistake in coding .vb.net code :- Protected Sub btnSave_Click(ByVal sender As Object, ByVal e AsEventArgs) Dim employmentID As Integer =Request.QueryString("employmentID") Dim resourceID As Integer = Request.QueryString("resourceID") Dim projectID As Integer = Request.QueryString("ProjectID") Dim dbconsave As SqlConnection dbconsave = New SqlConnection(HRISDBConnectionString) Dim dbcomsave As New SqlCommand("sp_save_NewHireEmailnotify",dbconsave) dbcomsave.CommandType = CommandType.StoredProcedure dbcomsave.Parameters.Add(New SqlParameter("employmentID",SqlDbType.Int)) dbcomsave.Parameters("employmentID").Value = employmentID dbcomsave.Parameters.Add(New SqlParameter("resourceID",SqlDbType.Int)) dbcomsave.Parameters("resourceID").Value = resourceID dbcomsave.Parameters.Add(New SqlParameter("ProjectID",SqlDbType.Int)) dbcomsave.Parameters("ProjectID").Value = projectID dbconsave.Open() dbcomsave.Parameters.Add("@PreferredFirstName",SqlDbType.VarChar) dbcomsave.Parameters.Item("@PreferredFirstName").Value =txtPreferredFirstName.Text.ToString() dbcomsave.Parameters.Add("@PreferredLastName",SqlDbType.VarChar) dbcomsave.Parameters.Item("@PreferredLastName").Value =txtPreferredLastName.Text.ToString() dbcomsave.Parameters.Add("@CellPhone", SqlDbType.VarChar) dbcomsave.Parameters.Item("@CellPhone").Value =txtCellPhone.Text.ToString() dbcomsave.Parameters.Add("@HomePhone", SqlDbType.VarChar) dbcomsave.Parameters.Item("@HomePhone").Value =txtHomePhone.Text.ToString() dbcomsave.Parameters.Add("@HomeAddressLine1",SqlDbType.VarChar) dbcomsave.Parameters.Item("@HomeAddressLine1").Value =txtHomeAddressLine1.Text.ToString() dbcomsave.Parameters.Add("@HomeAddressLine2",SqlDbType.VarChar) dbcomsave.Parameters.Item("@HomeAddressLine2").Value =txtHomeAddressLine2.Text.ToString() dbcomsave.Parameters.Add("@HomeAddressState",SqlDbType.VarChar) dbcomsave.Parameters.Item("@HomeAddressState").Value =txtHomeAddressState.Text.ToString() dbcomsave.Parameters.Add("@HomeAddressCity",SqlDbType.VarChar) dbcomsave.Parameters.Item("@HomeAddressCity").Value =txtHomeAddressCity.Text.ToString() dbcomsave.Parameters.Add("@HomeAddressZIP", SqlDbType.VarChar) dbcomsave.Parameters.Item("@HomeAddressZIP").Value =txtHomeAddressZIP.Text.ToString() dbcomsave.Parameters.Add("@HomeAddressCountry",SqlDbType.VarChar) dbcomsave.Parameters.Item("@HomeAddressCountry").Value =txtHomeAddressCountry.Text.ToString() dbcomsave.Parameters.Add("@ArrangementType",SqlDbType.VarChar) dbcomsave.Parameters.Item("@ArrangementType").Value =ddlArrangementType.SelectedItem.ToString() dbcomsave.Parameters.Add("@PracticeGroup", SqlDbType.VarChar) dbcomsave.Parameters.Item("@PracticeGroup").Value =ddlPracticeGroup.SelectedItem.ToString() dbcomsave.Parameters.AddWithValue("@EquipmentNeeds",txtEquipmentNeeds.Text.ToString()) Try dbcomsave.ExecuteNonQuery() lblMessage.Text = "Record saved successfully" Catch ex As Exception End Try dbconsave.Close() End Sub==============================================================================.aspx code :-<table> <tr> <td > <asp:LabelID="lblPreferredFirstName" runat="server" Text="Name(Preferred FirstLast) :" ForeColor="Blue"></asp:Label> </td> <td <asp:TextBoxID="txtPreferredFirstName" runat="server" Text="" BorderStyle="None"></asp:TextBox> <asp:TextBoxID="txtPreferredLastName" runat="server" Text="" BorderStyle="none" ></asp:TextBox> </td> </tr> <tr> <td > <asp:Label ID="lblCellPhone"runat="server" Text="CellPhone :" ForeColor="Blue"></asp:Label> </td> <td > <asp:TextBox ID="txtCellPhone"runat="server" Text="" ></asp:TextBox> </td> </tr> <tr> <td > <asp:Label ID="lblHomePhone"runat="server" Text="HomePhone :" ForeColor="Blue"></asp:Label> </td> <td > <asp:TextBox ID="txtHomePhone"runat="server" Text="" ></asp:TextBox> </td> </tr> <tr> <td > <asp:LabelID="lblHomeAddressLine1" runat="server" Text="HomeAddressLine1 :"ForeColor="Blue"></asp:Label> </td> <td > <asp:TextBoxID="txtHomeAddressLine1" runat="server" Text="" ></asp:TextBox> </td> </tr> <tr> <td > <asp:LabelID="lblHomeAddressLine2" runat="server" Text="HomeAddressLine2 :"ForeColor="Blue"></asp:Label> </td> <td > <asp:TextBoxID="txtHomeAddressLine2" runat="server" Text="" ></asp:TextBox> </td> </tr> <tr> <td > <asp:LabelID="lblHomeAddressState" runat="server" Text="HomeAddressState :"ForeColor="Blue"></asp:Label> </td> <td > <asp:TextBoxID="txtHomeAddressState" runat="server" Text="" ></asp:TextBox> </td> </tr> <tr> <td > <asp:LabelID="lblHomeAddressCity" runat="server" Text="HomeAddressCity :"ForeColor="Blue"></asp:Label> </td> <td > <asp:TextBoxID="txtHomeAddressCity" runat="server" Text="" ></asp:TextBox> </td> </tr> <tr> <td > <asp:LabelID="lblHomeAddressZIP" runat="server" Text="HomeAddressZIP :"ForeColor="Blue"></asp:Label> </td> <td > <asp:TextBoxID="txtHomeAddressZIP" runat="server" Text="" ></asp:TextBox> </td> </tr> <tr> <td > <asp:LabelID="lblHomeAddressCountry" runat="server" Text="HomeAddressCountry :"ForeColor="Blue"></asp:Label> </td> <td > <asp:TextBoxID="txtHomeAddressCountry" runat="server" Text="" ></asp:TextBox> </td> </tr> <tr> <td > <asp:Label ID="lblArrangement"runat="server" Text="Arrangement :" ForeColor="Blue"></asp:Label> </td> <td > <asp:DropDownListID="ddlArrangementType" runat="server" Width="160px"DataSourceID="ObjectDataSourceArrangementType"DataTextField="ArrangementType" DataValueField="ArrangementType"OnDataBound="ddlArrangementType_DataBound"> </asp:DropDownList> <%--<asp:TextBoxID="txtArrangement" runat="server" Text="" ></asp:TextBox>--%> </td> </tr> <tr> <td > <asp:LabelID="lblPracticeGroup" runat="server" Text="Practice Group :"ForeColor="Blue"></asp:Label> </td> <td > <asp:DropDownListID="ddlPracticeGroup" runat="server" Width="160px"DataSourceID="ObjectDataSourcePracticeGroup"DataTextField="PracticeGroup" DataValueField="PracticeGroup"OnDataBound="ddlPracticeGroup_DataBound"> </asp:DropDownList> <%--<asp:TextBoxID="txtPracticeGroup" runat="server" Text="" ></asp:TextBox> --%> </td> </tr></table>please help me to solve the issue.Thanks in advance
View Replies !
Dropdownlist Resetting On Post Back, ??SQL 2005 Express Database Problem
Hi all, I am trying to write a web page connected to an sql database of my MP3 files. I have a dropdown list box that populates with the artist, this hopefully being used to filter results into a datagrid. However, i am having a problem with the ddlb box repopulating on post back, i trawled the news groups and coded the population of the ddlb within an "if not page.postback" statement but to no avail. If i connect the ddlb to another sql database i have, the page reloads with the selctedvalue retained. So the theory is now that it is the SQL database, (is this a limitation of SQL express?) and i am having troubleshooting this. Here is the SQL of the databse: USE [mp3]GO/****** Object: Table [dbo].[Table_1] Script Date: 04/21/2008 20:40:21 ******/SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOCREATE TABLE [dbo].[Table_1]([Title] [nvarchar](50) NOT NULL,[Artist] [nvarchar](50) NULL,[Album] [nvarchar](50) NULL,[Year] [nvarchar](25) NULL,[Comment] [nvarchar](500) NULL,[TrackNumber] [nvarchar](10) NULL,[path] [nvarchar](300) NOT NULL,[genre] [nvarchar](25) NULL,[id] [int] IDENTITY(1,1) NOT NULL,CONSTRAINT [PK_Table_1_1] PRIMARY KEY CLUSTERED ([id] ASC)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]) ON [PRIMARY] Any help much appreciated. Cheers Billy
View Replies !
How Can I Fill Data In Textboxes From Sql Databases But Two Different Tables When I Select A Name That Is Inside A Dropdownlist
HI I need help how can i fill data in textboxes from sql databases but two different tables when i select a name that is inside a dropdownlist my controls are as follows <asp:DropDownList ID="ddl" runat="server" DataSourceID="SqlDataSource13" DataTextField="fullname" DataValueField="fullname"> </asp:DropDownList> <asp:SqlDataSource ID="SqlDataSource13" runat="server" ConnectionString="<%$ ConnectionStrings:NPI Employee MasterConnectionString2 %>" SelectCommand="SELECT [FirstName]+' '+ [Surname] as fullname FROM [Employee] where CurrentEmployee_YN=1 order by FirstName "></asp:SqlDataSource><table bordercolor="#111111" cellpadding="0" cellspacing="0" style="width: 100%; border-collapse: collapse; height: 32px; visibility: hidden;" id="table0"> <tr> <td style="width: 159px; visibility: hidden;"> </td> <td style="width: 170px"> </td> <td bgcolor="#eeeddb" style="width: 20%; height: 25px"> <strong> Order No:</strong></td> <td bgcolor="#eeeddb" style="width: 26%; height: 25px"> <asp:Label ID="OrderNo" runat="server" Width="104px"></asp:Label></td> </tr> <tr> <td bgcolor="#eeeddb" style="width: 159px; height: 25px"> <strong> Account No:</strong></td> <td bgcolor="#eeeddb" style="width: 170px"> <asp:TextBox ID="AccountNo" runat="Server" MaxLength="10" Width="130px"></asp:TextBox> <asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server" ControlToValidate="AccountNo" Display="Static" ErrorMessage="Enter Acc No." Text="*"></asp:RequiredFieldValidator></td> <td bgcolor="#eeeddb" style="width: 20%; height: 25px"> <strong> Today's Date:</strong></td> <td> <asp:Label ID="Label1" runat="server" Text="Label" Width="200px"></asp:Label></td> </tr> <tr> <td bgcolor="#eeeddb" style="width: 159px; height: 25px"> <strong> Travel Consultant:</strong></td> <td bgcolor="#eeeddb" style="width: 170px"> <asp:TextBox ID="Consultant" runat="Server" MaxLength="30" Width="128px"></asp:TextBox> <asp:RequiredFieldValidator ID="RequiredFieldValidator7" runat="server" ControlToValidate="Consultant" Display="Static" ErrorMessage="Enter Travel Consultant." Text="*"></asp:RequiredFieldValidator></td> </tr> </table> <center> </center> <center> </center><table bordercolor="#111111" cellpadding="0" cellspacing="0" style="width: 80%; border-collapse: collapse; height: 32px; display: block; visibility: hidden;" id="table2"> <tr> <td align="center" bgcolor="#ffcc33" colspan="3" style="width: 90%; height: 29px"> <font color="#000000" size="5">Enter Passenger(s) Details</font></td> </tr> <tr> <td bgcolor="#eeeddb" style="width: 31%; height: 25px"> <strong> Surname:</strong></td> <td bgcolor="#eeeddb" style="width: 57%; height: 25px"> <asp:TextBox ID="Surname" runat="Server" MaxLength="30" Width="148px"></asp:TextBox> <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="Surname" Display="Static" ErrorMessage="Enter Surname." Text="*"></asp:RequiredFieldValidator></td> </tr> <tr> <td bgcolor="#eeeddb" style="width: 31%; height: 20px"> <strong> Name:</strong></td> <td bgcolor="#eeeddb" style="width: 57%; height: 20px"> <asp:TextBox ID="Name" runat="Server" MaxLength="30" Width="148px"></asp:TextBox> <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="Name" Display="Static" ErrorMessage="Enter Name." Text="*"></asp:RequiredFieldValidator></td> </tr> <tr> <td bgcolor="#eeeddb" style="width: 31%; height: 25px"> <strong> Initials:</strong></td> <td bgcolor="#eeeddb" style="width: 57%; height: 25px"> <asp:TextBox ID="Initials" runat="Server" MaxLength="5" Width="148px"></asp:TextBox> </td> </tr> <tr> <td bgcolor="#eeeddb" style="width: 31%; height: 25px"> <strong> Title:</strong></td> <td bgcolor="#eeeddb" style="width: 57%; height: 25px"> <asp:DropDownList ID="DropDownList1" runat="server" Width="156px"> <asp:ListItem></asp:ListItem> <asp:ListItem Value="Mr"></asp:ListItem> <asp:ListItem Value="Mrs"></asp:ListItem> <asp:ListItem Value="Ms"></asp:ListItem> <asp:ListItem Value="Dr"></asp:ListItem> <asp:ListItem Value="Prof"></asp:ListItem> <asp:ListItem Value="Min"></asp:ListItem> <asp:ListItem Value="Other"></asp:ListItem> </asp:DropDownList> <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="Dropdownlist1" Display="Static" ErrorMessage="Select Title." Text="*" Width="20px"></asp:RequiredFieldValidator> </td> </tr> <tr><td bgcolor="#eeeddb"> <strong> Department</strong> </td> <td bgcolor="#eeeddb" style="width: 57%; height: 25px"> <asp:TextBox ID="Department" runat="server"></asp:TextBox></td> </tr> <tr><td bgcolor="#eeeddb"> <strong> Cost Centre</strong> </td> <td bgcolor="#eeeddb" style="width: 57%; height: 25px"> <asp:TextBox ID="CostCentre" runat="server"></asp:TextBox></td> </tr> <tr> <td bgcolor="#eeeddb" style="width: 31%; height: 25px"> <strong> Tel:</strong></td> <td bgcolor="#eeeddb" style="width: 57%; height: 25px"> <input id="Tel" runat="SERVER" maxlength="15" name="Tel" onkeypress="if((event.keyCode<48)|| (event.keyCode>57))event.returnValue=false" style="width: 143px" type="text" /> </td> </tr> <tr> <td bgcolor="#eeeddb" style="width: 31%; height: 25px"> <strong> Fax:</strong></td> <td bgcolor="#eeeddb" style="width: 57%; height: 25px"> <input id="Fax" runat="SERVER" maxlength="15" name="Fax" onkeypress="if((event.keyCode<48)|| (event.keyCode>57))event.returnValue=false" style="width: 143px" type="text" /> </td> </tr> </table> cost centre and department are from cost table and the rest are from employee table
View Replies !
Unable To Pass Null Value With DropDownList Parameter In Reporting Services 2005
Hello, I have a stored procedure that on two fields it allows null. On the report, I have two DropDownList boxes that are populated with data, however, I would like the user to be able to have the option of not selecting an item from these list, thus passing null to the stored procedure. When I goto "Report | Report Parameters" I have set these fields to "allow null" and "allow blank" and at the bottom I also gave it the default value of null. When I run the report in preview mode, those two dropdownlist have a <Select a Value> and my assumption is since I want them to pass null, I will just leave them that way. However, when the report is ran, I receive an error saying "Please select a value for the parameter: (my parameter)". So it forces me to select an option at which I don't want to do. How can I set this to pass a null? Thanks, Flea#
View Replies !
Declare @var????
I am trying to get a grasp on the Sql Stored procedures it seems i dont really understnad what DECLARE @Date DateTime means??? I mean i think it means that i am just declaring a varible name Date that will hold a DateTime Value??? is that correct or is it more to it???? CREATE PROCEDURE dbo.Tracking_GetStatus AS DECLARE @Date DateTime DECLARE @Begining DateTime DECLARE @Ending DateTime SET @Date = GETDATE() SET @Begining = DATEADD(ss,(DATEPART(ss,@Date)*-1), DATEADD(mi,(DATEPART(mi,@Date)*-1), DATEADD(hh,(DATEPART(hh,@Date)*-1),@Date))) SET @Ending = DATEADD(ss,-1, DATEADD(dd,1,DATEADD(ss,(DATEPART(ss,@Date)*-1), DATEADD(mi,(DATEPART(mi,@Date)*-1), DATEADD(hh,(DATEPART(hh,@Date)*-1),@Date))))) SELECT Vehicl, UpdateTi XCoord, YCoord, Status FROM Track WHERE UpdateTime >= @Begining AND UpdateTime <= @Ending RETURN GO
View Replies !
DECLARE In SQL CE
Can I use DECLARE in SQL 2005 Compact, and if not, how do I do INSERTs into tables which have columns with Primary Key constraints? Matt
View Replies !
Must Declare Scalar @.....
Hi everyone, I am getting that infamous message on an INSERT Sql query. I am doing everything right by the looks of it. All variables are either passed in through a custom form, or else declared and initialised in the body of the script. I post the relevent code below: SQLsqlInsertEmail = "INSERT INTO CandidateLogins (SiteID, LoginName, CandidateEmail, DateRegistered) " & _" VALUES (@SiteID, @LoginName, @CandidateEmail, @DateRegistered); SELECT SCOPE_IDENTITY()"Try sqlSetCandidateEmail.Parameters.Add(New SqlParameter("@SiteID", SqlDbType.Int)) sqlSetCandidateEmail.Parameters("@SiteID").Value = SiteID sqlSetCandidateEmail.Parameters.Add(New SqlParameter("@LoginName", SqlDbType.VarChar)) sqlSetCandidateEmail.Parameters("@LoginName").Value = userName sqlSetCandidateEmail.Parameters.Add(New SqlParameter("@CandidateEmail", SqlDbType.VarChar)) sqlSetCandidateEmail.Parameters("@CandidateEmail").Value = email sqlSetCandidateEmail.Parameters.Add(New SqlParameter("@DateRegistered", SqlDbType.DateTime)) sqlSetCandidateEmail.Parameters("@DateRegistered").Value = DateRegistered sqlSetCandidateEmail = New SqlCommand(sqlInsertEmail, C4LConnection) C4LConnection.Open() CandidateID = sqlSetCandidateEmail.ExecuteScalar() Catch Exp As SqlException lblResults.Visible = True lblResults.Text = "Unable to Register Jobseeker: " & Exp.MessageFinallyC4LConnection.Close()End Try All the variables passed into the SQL statement are initialised, with SiteID beign set to '0', rather than Null (none of the fields are Nullable in the database table) and I have checked that the SqlDbType's correspend to the Table Definition So far as I can discern, everything is correct and as can be seen, I am not using a stored procedure in this instance, but the script falls over be producing the error message "Must Declare Scalar @SiteID", even though SiteID is declared as Int32 further up in the script. Any help would be appreciated.
View Replies !
'declare' Syntax In A UDF
Hi, I'm trying to create a function that returns a table, however I wantto use a local variable in there and enterprise manager ain't liking it!The error I get is number 156 'incorrect syntax near the keyword'declare'.. hopefully this is just a simple thing where I've put it inthe wrong place.The code follows:CREATE FUNCTION AFGroupedTotals (@campaign nvarchar(30),@datefromsmalldatetime, @dateto smalldatetime, @prospect nvarchar(30), @typenvarchar(20))RETURNS TABLE ASRETURNdeclare @set nvarchar(150)select "Total Pledged" as info, sum(total) as totFROM AFresponseTotals (@campaign, @datefrom, @dateto,@prospect)Cheers for any help,Chris
View Replies !
Declare @var Text
Hi, I want to store more than 8000 characters. Ideally it might have been fine if decalre @var text had worked for me. Can anyone tell is it possible.... thanks, sajai.
View Replies !
DECLARE CURSOR
Is there any way to create a cursor, based on a dynamically created select_statement? Something like: DECLARE someCRS CURSOR LOCAL FAST_FORWARD FOR @strSelect where @strSelect is previously declared as let's say varchar. I don't want to create a stored procedure for this. Thanks!
View Replies !
|