DataSource Controls :: DropDownList And PageMethods?
Jun 22, 2010[Code]....
DropDownList and PageMethods?
[Code]....
DropDownList and PageMethods?
i use 2 dropdownlist with 2 object data source first dropdownlist to display departments name using object datasource (field to display DeptName , value of field DeptID)
second dropdownlist to display Employee name but depend on departments (field to display EmpName , value of field EmpID)
how to display employee name in dropdownlist depend on departments name in the other dropdownlist
2 tables
1 table deprtments with column (DeptID , DeptName , DeptDescription)
2 table Employee with column (EmpID , DeptID , EmpName)
I am trying to use pagemethods using scriptmanager. i have managed to return dataset in xml format but not able to proceed how can i bind the data to gridview using pagemethods. here is my code.
[Code]....
here is my aspx page code
[Code]....
I'm using a SP to fill the drop down list and when I look at the values in the drop down list the first row of the dataset is missing.Here's the code I'm using, I've left out the database connection info and the link to the SP
StaffListRS = cmdStaff.ExecuteReader()
If StaffListRS.Read() Then
ddlStaffList.Datasource = StaffListRS
ddlStaffList.DataTextField = "StaffName"
ddlStaffList.DataValueField = "NewStaffID"
ddlStaffList.DataBind()
ddlStaffList.Items.Insert(0, New ListItem("All", 0)
If
Trying to add another 2nd dropdownlist to Query String... Below This Query String works Perfectly:
Query = String.Format("SELECT {0} FROM {1} WHERE NACategory = '{2}' ORDER BY {3}", PrimaryKeyColumn, TableName, DDLCategory.SelectedItem.Text, SetSorting())
I've tried to add a 2nd DDLSubCategory.SelectedItem.Text - But its throwing and error message.
Exception of type System.StackOverflowException was thrown.
Query = String.Format("SELECT {0} FROM {1} WHERE NACategory = '{2}' AND NASubCategory = '{3}' ORDER BY {4}", PrimaryKeyColumn, TableName, DDLCategory.SelectedItem.Text,
DDLSubCategory.SelectedItem.Text, SetSorting())
Can Someone take a look I'm not sure how to write (add) 2nd DropdownList (DDLSubCategory.SelectedItem.Text)
My application includes a gridview control with and Edit mode which allows users to do selections using cascading dropdownlist. My code is based on tutorial by Brian Orrell (link below). I am able to statically populate the dropdownlist but in my case I need to populate it dynamically based on a previous selection of a dropdownlist, I would like to do it programatically so I can manipulate data.
[URL]
I'm having trouble linking a form view I have on a web page with a drop down list on the same page. Basically, what I need to happen is whenever a new selection is chosen from the drop down list, the details in the form view should also change to represent that selection's criteria.
I have my drop down list connected to SQLDataSource1 and my form view to SQLDataSource2, and these are populating as expected, it's just the problem lies when changing the selection in the drop down list - the form view doesn't follow what is selected.
does anything have to be added in the properties options of either the data source controls or the form view? For example, in the "Events" section, there is a "DataBinding" and "DataBound" selection item that can be used - should anything be entered in this to connect the two?
PS - Here is the code I have in the back end of the page:
[Code]....
i have a DAL function to get the records from DB. it will return a dataset. now i want to use linq from dataset and bind the dropdownlist, gridview data comtrols. pls any one give me a sample. also i want to know whether we can use distinct, fileter in linq.
View 4 RepliesI have 5 dropdown list (sector-country-year-project code-project title) so what i need is when i select specific sector for example education , the rest of the label should show me the only data related to the sector education in dropdown list. the same with other if i select year 2011 should show me in other dropdown list just the data related to year 2011.
View 1 RepliesI have SqlDataSource with a few parameters (code below). If I understand this code correctly if parameter is NULL I should receive all items from the query. It works fine with query editor. But when I try to use this query on my page - with DropDownList and Textbox controls as source of parameters - it doesn't work. I suspect that main reason of problem is value which these controls pass to the query. Instead of NULL this is an empty string. Is it possible to pass NULL value from DropDownList or TextBox to
the SqlDataSource?
[Code]....
[Code]....
Trying to Add a Dropdownlist Selection to a Query String. When I use this :
[Code]....
if I have three Dropdownlist A, B, C, how can I write a select statement to get data from sql server based on the dropdownlist selected.e.g. if user select dropdownlist A, select * from table where A = dropdownlist A but if user select dropdownlist A and C, then select statment is "select * from table where A = dropdownlist A and B = dropdownlist B or if selected A, B, C.......how can I settle so many choice.
View 2 Repliesi think i can't see the forrest for the trees.......there HAS to be a simple way to do this. so i created a web page and on that page i have two dropdown lists. the first is STATE and the second is COUNTY. the STATE is a static list. but the COUNTY is generated whenever the STATE changes. now....when i set up the COUNTY dropdown list, it prompted me for a datasource. i have a store procedure which takes the 2-letter STATE code and returns all the counties for that state. so i set up the datasource for the COUNTY drop down list by just following the prompts from visual studio. i gave it a default state of Alabama (AL). and all is fine. so here's my question: how can i reload the datasource and subsequently the COUNTY dropdown list? i see no way to access the datasource that the environment generated for me.
well.....i thought.......i'll just do it the old fashioned way and set up a command.......connectionstring.......and sql statement and load the results into a datareader (do i REALLY have to do all that?)
but it still doesn't work. what's the simplest way for me to just re-fire my stored procedure and pass it the STATE parameter and reload the datasource and dropdown list?
I have several dropdownlists which are databound to a SQL DB but I am also needing to add 2 items to them. I am using the code below.
With the code in the Calendar1_SelectionChanged sub (Which is when I want it to fire) It loads the data from the sql but not the static content
If I move the code to the Page_Load sub and add "If Page.IsPostBack Then" then it loads the static content but not the SQL.
[Code]....
[Code]....
i am using gridview control and a linqdatasource and its all working fine and i have added the functionlity of searchingBySubject and i added WhereParameters and than binding my gridview (see the code below) but somehow its not returning any rows and i see i have number of rows based on what i am searching.
I am working to retrieve list of values from database according to the dropdownlist value in view page in asp.net using linq to sql.I am having the dropdown values as static values.I am using table view to display the details.
View 2 RepliesI have a problem with connecting a DropDownList to a DataSource.
The scenario: When I add am item to the database (I do this using a GridView/ObjectDataSource / SPROC) I want to update a DropDownList that lists this items as well.This DropDownList is linked with another ObjectDataSource. Now, I listen to the RowCommand event of the GridView and in a certain case I refresh the DataSource of the DrpoDownList and do a DataBind to the DropDownList afterwards.
The strange thing is, that when I take a look at the DropDownList's Items-Collection during the Page's OnPreRender event handling, the items collection contains the new entry but the new entry is not rendered, i.e. when I take a look at the rendered HTML the <option></option> entry for the new value is missing.
After another postback to the page the entry appears in the DropDownList?
i am a new user of asp.net and i am a learner so i just want to connect two dropdownlist to data souce and i want that the list item of second dropdown is changed according to change of selected item of first dropdown.
i have connect it to data source successfully it getting chaged items but it happance only when its load then if i select the next item of first one it would not work properly.
The title pretty much says it all.
I'm trying to pass the selected value of a dropdown list to a stored procedure that will return a set of results based on the value passed.
I am trying to use a datasource with a dropdownlist. Eventually, my data source method to call a stored procedure and load the datatable is returns, but for now, I am just creating the datatable manually. I need each item to have two attributes, the text, whixh the user will see in the DDL, and the value that the program will retrieve from and store back to the file.
It is partly working in that the DDL has 3 items, however the text for each item reads "System.Data.DataRowView"
I have to be close, but I can't figure out what I am doing wrong.
[Code]....
I have a Dropdownlist in an itemTemplate in a gridview. My gridView binds to dataTable1 (from which the selected value for dropdown comes from) and dropDown binds to dataTable2 (i need to get DataValueField and DataTextField from here).
[Code]....
i have a dropdownlist that bind with sqldatasource1. everytime i load this page, dropdownlist will display directly the content of data.
However, what i want is display empty message like --Please select your currency-- by default.
I have a partial class extending my Entity Model. I'd like to write a method that returns a collection of types from my entity framework model. For example, I'd like to get all the states to populate a drop down list. So I've written a method called getallstates(), similar to the example below:
[Code]....
I tried returning a list of Objects, and a list of states to my calling method to be used to bind to a drop down list. However I get an error that:
Server Error in Application. Unable to cast object of type 'System.Data.Objects.ObjectQuery to type 'System.Collections.Generic.List`1[System.Object]'.
What should my return type be for this function?
I have dropdownlist of dates and depending on the date that the user selects from list, I would like to filter records that fall between the startyear and finishyear columns in the datasource. (My the problem is that I do not know how to declare the Startyear and Endyear from the query in the code as they appear underlined - probably the BETWEEN syntax is wrong too).
yYear = DropDownList1.Text
Using connection As New SqlConnection("Data Source=CHRIS-PCSQLEXPRESS;Initial Catalog=TorGHL;Integrated Security=True")
Dim cmd As String
cmd = "SELECT BarDetails.*, MenuHeadingId AS Expr1 FROM BarDetails WHERE (MenuHeadingId = 2)" & "WHERE " & yYear & " BETWEEN " & "(" &
StartYear & ")" & " AND " & "(" & EndYear & ")"
connection.Open()
Dim dapubcb As New SqlDataAdapterDim sqlcomm
As
New SqlCommand(cmd, connection)
dapubcb.SelectCommand = sqlcomm
Dim dspubcb As New DataSet("BarDetails")
dapubcb.Fill(dspubcb, "BarDetails")
I am using a DataGridView and have a master table which contains values which different tables related to the master data, i.e. StatusID =1 in master table = TrailerStatus (1, 2, 3, 4 and their descriptions) are in a related table. I am able to retrieve the values from Table B 1 = Empty, 2 = Rejected, 3 = Onsite, etc. However, I don't know how to relate the master table StatusID = 1 to default my dropdown list from the relational table 1, 2, 3, 4.
I have been fighting with this for quite some time and just have not found a solid example of how to do this. I actually have two dropdownlists which will need to be correctly wired in order for my application to work.
This will also be an editable dataGridView but I will tackle that challenge once I get this first hair plucked from my butt.
There is some code-behind which doesn't work at all pertaining to a ;; gvSCACDetail_RowDataBound ;;
but I dont' think I can even get the code to compoile when this is not commented out.
Here are some of the details:
<td style="width: 700px; height: 20px">
<asp:GridView ID="gvSCACDetail" runat="server" AutoGenerateColumns="False" AutoGenerateEditButton="True" DataKeyNames="trailerid,locationid,scacid,statusid,capacityid" AutoGenerateDeleteButton="True" DataSourceID="SCACDetailView" Visible="False" Width="698px">
<PagerStyle CssClass="centerh" HorizontalAlign="Center" />
[Code]....