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 DropDownList
VendorID = CType(CreateUserWizard1.FindControl("VendorName"), DropDownList)
Dim MyReader As SqlDataReader
Dim sel As String = String.Format("SELECT VendorID, Name FROM Vendors")
Dim MyCommand As SqlCommand
MyCommand = New SqlCommand
MyCommand.CommandText = sel
MyCommand.CommandType = CommandType.Text
MyCommand.Connection = SqlConnection
MyCommand.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 = MyReader
Line 30: VendorID.DataValueField = "VendorID"
Line 31: VendorID.DataTextField = "Name"
HiHoping someone can help me , I am looking to add a file upload inside a createuserWizard but am banging my head at this stage I can get in working saving the file selected in the Fileupload into a table on the database using a datatype "image" for the field.However ideally I would like to save a string of the file path to the database and save the actual file to the filesystem of the webserver.The problem for me is that this is inside a CreateUserWizard, I gather the standard information and them have "extended" the wizard by adding another wizard step , which will include a FileUpload control. I need to invoke the FileUpload when the user select the createUser button of the CreateUserWizard control( CreateUserWizard1_CreatedUser in the aspx.cs) I am able to write the SQL that allows save information from a textbox to a database tabel but not able to write the functionality to 1.Uplaod file to webServer when user selects Create User button 2. Save this path in a table on the database.I've tried loads but cannot get it to work I'm using C# for this. here's a scaled down version of my code with just teh CreateUserWizard which contains the fileUploadaspx ( Contains a create user Wizard which inturn contains a Fileupload) <%@ Page Language="C#" AutoEventWireup="true" CodeFile="FORUMcreateuser.aspx.cs" Inherits="_Default" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" ><head id="Head1" runat="server"> <title>Sign Up Page</title></head><body> <form id="form1" runat="server" enctype="multipart/form-data"> <atlas:ScriptManager id="MasterScriptManager" EnableScriptGlobalization="false" runat="Server"></atlas:ScriptManager> <div> <asp:CreateUserWizard ID="CreateUserWizard1" runat="server" BackColor="White" BorderColor="#FFDFAD" BorderStyle='Solid' BorderWidth='1px' Font-Names='Verdana' Font-Size='0.8em' OnCreatedUser='CreateUserWizard1_CreatedUser'> <WizardSteps> <asp:WizardStep ID="CreateUserWizardStep0" runat="server"> <table id="Table2" style='width: 100%'> <tr> <td style='color: blue'> <strong>Step 1 of 2</strong></td> <td style='color: white'> PlaceHolderBGColor</td> <td> </td> </tr> <tr> <td> </td> <td style='color: white'> </td> <td> </td> </tr> <tr> <td> First Name:</td> <td> <asp:TextBox runat="server" ID="txtFirstName" MaxLength="50" /> </td> <td> <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator15" ControlToValidate="txtFirstName" ErrorMessage="First Name is required." /> </td> </tr> <tr> <td> Last Name:</td> <td> <asp:TextBox runat="server" ID="txtLastName" MaxLength="50" /> </td> <td> <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator16" ControlToValidate="txtLastName" ErrorMessage="Last Name is required." /> </td> </tr> <tr> <td> </td> <td style='color: white'> PlaceHolderBGColor</td> <td> </td> </tr> <tr> <td> File:</td> <td> <asp:FileUpload ID="FileUpload1" runat="server" /> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> </tr> </table> <br /> </asp:WizardStep> <asp:CreateUserWizardStep ID="CreateUserWizardStep2" runat="server"> <ContentTemplate> <table> <tr> <th align="left" style='color: blue'> Step 2 of 2</th> </tr> <tr> <th align="left"> MRS Login Details </th> </tr> <tr> <td>Username:</td> <td> <asp:TextBox runat="server" ID="UserName" /> <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator9" ControlToValidate="UserName" ErrorMessage="Username is required." /> </td> </tr> <tr> <td>Password:</td> <td> <asp:TextBox runat="server" ID="Password" TextMode="Password" /> <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator10" ControlToValidate="Password" ErrorMessage="Password is required." /> </td> </tr> <tr> <td>Confirm Password:</td> <td> <asp:TextBox runat="server" ID="ConfirmPassword" TextMode="Password" /> <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator13" ControlToValidate="ConfirmPassword" ErrorMessage="Confirm Password is required." /> </td> </tr> <tr> <td>Email:</td> <td> <asp:TextBox runat="server" ID="Email" /> <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator11" ControlToValidate="Email" ErrorMessage="Email is required." /> </td> </tr> <tr> <td> Recover Password Question:</td> <td> <asp:TextBox runat="server" ID="Question" /> <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator12" ControlToValidate="Question" ErrorMessage="Question is required." /> </td> </tr> <tr> <td> recover Password Answer:</td> <td> <asp:TextBox runat="server" ID="Answer" /> <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator14" ControlToValidate="Answer" ErrorMessage="Answer is required." /> </td> </tr> <tr> <td colspan="2"> <asp:CompareValidator ID="PasswordCompare" runat="server" ControlToCompare="Password" ControlToValidate="ConfirmPassword" Display="Dynamic" ErrorMessage="The Password and Confirmation Password must match."></asp:CompareValidator> </td> </tr> <tr> <td colspan="2"> <asp:Literal ID="ErrorMessage" runat="server" EnableViewState="False"></asp:Literal> </td> </tr> </table> <asp:SqlDataSource ID="InsertExtraInfo" runat="server" ConnectionString="<%$ ConnectionStrings:CONTACTSConnectionString %>" InsertCommand="INSERT INTO [CLIENT] ([client_id], [First_Name], [Last_Name]) VALUES (@UserId, @FirstName, @LastName)" ProviderName="<%$ ConnectionStrings:CONTACTSConnectionString.ProviderName %>"> <InsertParameters> <asp:ControlParameter Name="FirstName" Type="String" ControlID="txtFirstName" PropertyName="Text" /> <asp:ControlParameter Name="LastName" Type="String" ControlID="txtLastName" PropertyName="Text" /> </InsertParameters> </asp:SqlDataSource> </ContentTemplate> </asp:CreateUserWizardStep> <asp:CompleteWizardStep ID="CompleteWizardStep1" runat="server"> </asp:CompleteWizardStep> </WizardSteps> <NavigationButtonStyle BackColor="White" BorderColor="#CC9966" BorderStyle='Solid' BorderWidth="1px" Font-Names="Verdana" ForeColor="#990000" /> <HeaderStyle BackColor="#FFCC66" BorderColor="White" BorderStyle='Solid' BorderWidth='2px' Font-Bold="True" Font-Size="0.9em" ForeColor="#333333" HorizontalAlign="Center" /> <CreateUserButtonStyle BackColor="White" BorderColor="#CC9966" BorderStyle='Solid' BorderWidth="1px" Font-Names="Verdana" ForeColor="#990000" /> <ContinueButtonStyle BackColor="White" BorderColor="#CC9966" BorderStyle='Solid' BorderWidth="1px" Font-Names="Verdana" ForeColor="#990000" /> <SideBarStyle BackColor="#990000" Font-Size="0.9em" VerticalAlign="Top" /> <TitleTextStyle BackColor="#990000" Font-Bold="True" ForeColor="White" /> <SideBarButtonStyle ForeColor="White" /> </asp:CreateUserWizard> </div> </form></body></html> aspx.cs using System;using System.Data;using System.Configuration;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;public partial class _Default : System.Web.UI.Page{ protected void Page_Load(object sender, EventArgs e) { } protected void CreateUserWizard1_CreatedUser(object sender, EventArgs e) { TextBox UserNameTextBox = (TextBox)CreateUserWizardStep2.ContentTemplateContainer.FindControl("UserName"); SqlDataSource DataSource = (SqlDataSource)CreateUserWizardStep2.ContentTemplateContainer.FindControl("InsertExtraInfo"); MembershipUser User = Membership.GetUser(UserNameTextBox.Text); object UserGUID = User.ProviderUserKey; DataSource.InsertParameters.Add("UserId", UserGUID.ToString()); DataSource.Insert(); }}
Im trying to make an "createaccount-page" and followed this guide: http://aspnet.4guysfromrolla.com/articles/070506-1.aspx The problem is that I want to use a stored procedure instead...But Iam getting this message when pushing the create-button: "Procedure or function usp_MyProcedure has too many arguments specified" My stored procedure look like this: (maybe something is wrong here?) ALTER PROCEDURE usp_MyProcedure
INSERT INTO MyTable (UserID, FName, LName,) Values (@UserID, @FName, @LName)
RETURN My sqldatasource: <asp:SqlDataSource ID="InsertExtraInfo" runat="server" ConnectionString="<%$ ConnectionStrings:ASPNETDBConnectionString %>" ProviderName="<%$ ConnectionStrings:ASPNETDBConnectionString.ProviderName %>" InsertCommand="usp_MyProcedure" InsertCommandType="StoredProcedure"> <InsertParameters> <asp:ControlParameter Name="FName" Type="String" ControlID="tboxFName" PropertyName="Text" /> <asp:ControlParameter Name="LName" Type="String" ControlID="tboxLName" PropertyName="Text" /> </InsertParameters> </asp:SqlDataSource>The code behind-file is the same as the one in the article...
Hey all,I'm working in Visual Web Developer 2005 Express. I'm a total newb so please bare with me. I'm trying to add a step to my CreateUserWizard that I put in using the automatic site administration utility. I've added a wizard step in between the "Sign up for your new account" step and the "complete" step. The purpose of the new step is to collect additional information about the user. I've added a FormView control and used an SQLDataSource to link it to a new table in the database established by the administration utility, and set up the templates to recieve the data. The one kink in the process seems to be associating the UserID created in step one with the additional information submitted in step 2. I made a UserID column, of data type uniqueidetifier in my new table and set up a foreign key relationship with the UserID columns in the aspnet_Membership table and the aspnet_Users table. When I run it as is I get the following error after I try to insert the data entered in the second step (additional information) into my new database table:Implicit conversion from data type sql_variant to uniqueidentifier is not allowed. Use the CONVERT function to run this query I guess my question is: How do I take the UserID generated in step 1, and pass it into the new table and into the new row being created in step 2? If possible, I would like to do it without any code (haha probably not going to happen, but worth a shot) but any assistance anyone could offer would be greatly appreciated. Thanks everyone. Matt Downey
For inserting current date and time into the database, is it more efficient and performant and faster to do getDate() inside SQL Server and insert the value OR to do System.DateTime.Now in the application and then insert it in the table? I figure even small differences would be magnified if there is moderate traffic, so every little bit helps. Thanks.
I'm trying to execute a stored procedure within the case clause of select statement. The stored procedure returns a table, and is pretty big and complex, and I don't particularly want to copy the whole thing over to work here. I'm looking for something more elegant.
@val1 and @val2 are passed in
CREATE TABLE #TEMP( tempid INT IDENTITY (1,1) NOT NULL, myint INT NOT NULL, mybool BIT NOT NULL )
INSERT INTO #TEMP (myint, mybool) SELECT my_int_from_tbl, CASE WHEN @val1 IN (SELECT val1 FROM (EXEC dbo.my_stored_procedure my_int_from_tbl, my_param)) THEN 1 ELSE 0 FROM dbo.tbl WHERE tbl.val2 = @val2
SELECT COUNT(*) FROM #TEMP WHERE mybool = 1
If I have to, I can do a while loop and populate another temp table for every "my_int_from_tbl," but I don't really know the syntax for that.
Just wonder whether is there any indicator or system parameters that can indicate whether stored procedure A is executed inside query analyzer or executed inside application itself so that if execution is done inside query analyzer then i can block it from being executed/retrieve sensitive data from it?
What i'm want to do is to block someone executing stored procedure using query analyzer and retrieve its sensitive results. Stored procedure A has been granted execution for public user but inside application, it will prompt access denied message if particular user has no rights to use system although knew public user name and password. Because there is second layer of user validation inside system application.
However inside query analyzer, there is no way control execution of stored procedure A it as user knew the public user name and password.
Looking forward for replies from expert here. Thanks in advance.
Note: Hope my explaination here clearly describe my current problems.
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?
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.
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)'.
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 %>"
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
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()
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
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
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?
I am using Visual Studio 2005 & SQL Server. How do i implement a DDL for users to select which value to input. like i can with Access. i do not need a table i think. if not the table would have only ID & Value.?
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>
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..
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:
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,
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
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
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.
i have 2 dropdownlist which is ddlCategory and ddlItem.i want<<< a)both ddl get data from sql db.b)view the data in gridview. i need code in vb.net to retrieve and post.tq