Make GridView Respond To 2 Drop Down Lists

Mar 11, 2010

I have got 2 Drop Down Lists on my Form and 1 GridView. I want GridView to display the data according to selection from the Drop Down Lists. For Example, One Drop Down List contains Names and other contains Dates. Both the Drop Down Lists can post back. So if i select a name from 1st Drop Down list, the Grid View should show all the results according to that Name. Similarly if i select the Date from the other Drop Down List , the Grid View should show the results according to the dates. But i cant figure out as how to bind Grid View to respond to 2 Drop Down List. BTW i am binding both the Drop Down Lists and the Grid View to the DataSource Objects, which is getting data from the database.

View 2 Replies


Similar Messages:

C# - Editable GridView Distinct Drop Down Lists

Jun 3, 2010

I have a simple app I am messing around with its a basic Master/Details layout. The details panel is actually a tab panel and on one of the tab panels it has a GridView. Within that grid view it shows the "current" in database information with all cells as read only. I then have an add button that inserts a row into the GriView and allows the user to enter some information. The first item in my GridView is a DropDownList, which is populated from an ObjectDataSource. This drop down is basically my unique index and there can only be one selected value per GridView.

What is the best way to remove the values from the list that are already in the GridView? Do I just need to remove the data source and add a OnDataBinding method that iterates through the grid view and generates a valid list of values? I can't use a service method because if the user adds two rows they would have the option to insert duplicates description types.

View 1 Replies

Edit Gridview Row With Drop Down Lists Gets Too Wide - Use Popup Panels Instead?

Apr 16, 2010

I have a series of GridViews in a Tab Panel - databound to a generic List of Business Objects. The columns in the Gridview are all similar to the following:

<asp:TemplateField HeaderText="Company" SortExpression="Company.ShortName">
<ItemTemplate>
<asp:Label ID="lblCompany" runat="server" Text='<%# Bind("Company.ShortName") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:DropDownList ID="ddlCompany" runat="server"></asp:DropDownList>
</EditItemTemplate>
</asp:TemplateField>

The GridView generates the "Edit" link at the beginning of the row, all the events fire ok. The problem is that the data is getting long. When in 'display mode', it's fine because the GridView control is smart enough to break some text into multiple lines (in particular Project, Title and Worker names can get pretty long). The problem come in editing mode. Drop-down lists DON'T break entries into multiple lines (for obvious reasons). Going into Edit ode on a row in the Gridview can make the Griview expand horizontally to twice the screen size (blowing through the width limits in the Master page and CSS but that's only a related problem).
What I need is something like the ModalPopup - but trying to tie it to an ID in an EditItemTemplate gives me errors when the page renders (because the 'ddlXXXX' doesn't exist at the time). In addition I don't know how to dynamically populate the panel so that I can get a response from it (like the ID of the Company they selected)
.
I'm also trying to avoid javascript and would like this to be a 'pure' aspx/code-behind solution (for simplicity's sake among others).
All the examples I find are of Modal Popups with the panels pre-defined. Even if it (the popup panel) were something like a list of checkboxes, it could be databound to the SortedList I have ready to go and an OK/Cancel button combination to accept or ignore things. I'm just not sure of what goes where.

EDIT: Final solution looks as follows:

<asp:TemplateField HeaderText="Company" SortExpression="Company.ShortName">
<ItemTemplate>
<asp:Label ID="lblCompany" runat="server" Text='<%# Bind("Company.ShortName") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:LinkButton ID="lnkCompany" runat="server" Text='<%# Bind("Company.ShortName") %>'></asp:LinkButton>
<asp:Panel ID="pnlCompany" runat="server" style="display:none">
<div>
<asp:DropDownList ID="ddlCompany" runat="server" ></asp:DropDownList>
<br/>
<asp:ImageButton ID="btnOKCo" runat="server" ImageUrl="~/Images/greencheck.gif" OnCommand="PopupButton_Command" CommandName="SelectCO" />
<asp:ImageButton ID="btnCxlCo" runat="server" ImageUrl="~/Images/RedX.gif" />
</div>
</asp:Panel>
<cc1:ModalPopupExtender ID="mpeCompany" runat="server"
TargetControlID="lnkCompany" PopupControlID="pnlCompany"
BackgroundCssClass="modalBackground" CancelControlID="btnCxlCo"
DropShadow="true" PopupDragHandleControlID="pnlCompany" />
</EditItemTemplate>
</asp:TemplateField>

And in the code-behind, lstIDLabor is the generic List of data lines (of which Company is one of the properties that is also a business object) that is bound to the GridView:

Sub PopupButton_Command(ByVal sender As Object, ByVal e As CommandEventArgs)
Dim intRow As Integer
Dim intVal As Integer
RestoreFromSessionVariables()
Select Case e.CommandName
Case "SelectCO"
intRow = grdIDCostLabor.EditIndex
Dim ddlCo As DropDownList = CType(grdIDCost.Rows(intRow).FindControl("ddlCompany"), DropDownList)
intVal = ddlCo.SelectedValue
lstIDLabor(intRow).CompanyID = intVal
lstIDLabor(intRow).Company = Company.Read(intVal)
Case Else
'
End Select
MakeSessionVariables()
BindGrids()
End Sub

View 1 Replies

Web Forms :: How To Have 2 Cascading Drop Down Lists For The Same Drop Down List

Mar 12, 2010

How can I have 2 Cascading Drop Down Lists for the same Drop Down List?here is my problemi have 3 drop down lists read from database1- Schools List 2- Classes List3- Teachers ListEvery School will have more than 1 Class and more than 1 TeacherWhat I want is when user select a School from Schools Drop Down List then BOTH (Classes and Teachers) should be refreshed based on the School Drop Down List

View 1 Replies

AJAX :: How To Populate Drop Down Lists

Sep 27, 2010

I've been trying to get this to work for weeks. I am trying to use a cascading drop down to populate drop down lists. The service method is working as i'm able to view the data in the browser but when i run the application the drop down list is empty. see below for the service method.

[Code]....

The code for the drop down list:

Location Name:<asp:DropDownList ID="DropDownList3" runat="server">
</asp:DropDownList>
<asp:CascadingDropDown ID="CascadingDropDown1" runat="server"
Category="Locations"
TargetControlID="Dropdownlist3"
PromptText="[Select Location]"
ServicePath="~/LocationWebService.asmx"
ServiceMethod="GetLocation"
EmptyText="Nothing">
</asp:CascadingDropDown>

View 4 Replies

Handle A Model With A Lot Of Drop Down Lists In Mvc?

Dec 8, 2010

I have a model with a LOT of foreign keys. Right now, I'm populating view data:

ViewData["fieldname"]=new selectlist(entityframeworkmodel.foreigntable.ToList(),"fieldkey","valuefield");

I really don't like this approach. For one thing, I'm supposed to just name the field the same thing and trust that it will get stored in the model. I don't really understand how that works but it's a little worrisome.

Secondly, my code is now a bit of a mess.

//Address drop downs
ViewData["AddressType"] = new SelectList(ent.tblAddressTypes.ToList(), "AddressID", "AddressType");
//Contact Drop Downs
ViewData["ContactTitle"] = new SelectList(ent.tblContactTitles.ToList(), "ContactTitleID", "Title");
//Event

[Code]...

The other issue is I don't see how I can test this. I've written a repository method that just maps the id values from the drop downs into the respective EF objects.

How are other people dealing with this? I do set up these drop downs in a few places, so I thought about putting them in a controller method.

P.S. Kind of thinking about this: [URL]

View 1 Replies

SQL Server :: 2 Drop-down Lists In The SQL Does Not Work?

Jul 22, 2010

SELECT MenuItemID, MenuItemType, ItemName, PizzaToppings, Description, GraphicFileName FROM MenuItems
WHERE (MenuItemType = @MenuItemType) AND (ItemName = CASE WHEN @ItemName = - 1 THEN ItemName ELSE @ItemName END)I have created 2 drop-down box and a search button to display all records when one drop-down box is set to 'All"In the web-form I have set one of the drop-down box to value = -1 and appenddatabounditems to true.In the SQL I have typed the above but it does not work? Any one have an idea how this could be achieved with SQL?Essentially retrieving all records with the 'all' value selected.

View 1 Replies

Library Of Custom Drop Down Lists?

Mar 29, 2010

I am sorry if this has been asked before. I could not really find anything on it. What I need to do is to create a library of custom drop down lists that I can just in many different projects. I am not really sure how to get started on this or where to look. An example of some of the lists I need are: states, gender, marital status.

View 8 Replies

Creating Multiple Querystrings From Drop Down Lists?

Feb 19, 2011

I have a gridview which can be filtered from one or more values in a querystring. That all works great: e.g. "?subject=Maths&authorName=Bond_James&type=Magazine"

The values passed to the query string come from 3 drop down lists: Subject, Author, Type. What I'd like is when the user presses "Filter" it will take the selected values from the drop down lists and pass them to the querystring - it could be 1 value, 2, or all 3 (like above).

The drop down lists have an item called "All Subjects" / "All Author" / "All Type" each with a value of -1. The idea being that if the user leaves these items selected then the Filter button just ignores them.

Here is my code so far:

[Code]....

Also, one more thing. How do I get the drop down lists to have the filters selected when the page re loads?

EDIT: I changed the default values of the drop down lists to "" - this leaves the URL looking messy though ?author=&subject=&type= This works, is it the best way?

View 2 Replies

MVC - How To Organize Commonly Used Drop-down Lists In Many Views

Jan 8, 2010

I am trying to understand how best to organize some common Dropdown lists used in several views (some are cascading)

Is it best to create a single ModelsCommonQueries then create a webservice for each dropdown used in cascading situation then have a single controller that contains actions for each dropdowns

This way I can follow DRY principle and not repeat the dropdown logics since they are used in various views.

View 1 Replies

Validating AJAX Cascading Drop Down Lists?

Mar 17, 2010

I am using the AJAX Cascading drop down list but want to add event validation e.g. the compare validators.

As the cascading drop down list requires the page event validation to be disabled what is the best way to do the validation?

Validation Attempt: I have tried to use a custom validator which calls a Javascript function but it doesnt seem to be picking up the control. I get the following error Microsoft JScript runtime error: Object required

function ValidateCostCentCat(source, arguments)
{
var countryList = document.getElementById("ddlCategory");
if (null != countryList)
{
var iValue = countryList.options[countryList.selectedIndex].value;
if (iValue == "Select Category")
{
arguments.IsValid = true;
}
else
{
arguments.IsValid = false;
}
}
}

The mark-up for the custom validator is

<asp:CustomValidator ID="valcustCategory" runat="server" CssClass="error" Display="Dynamic" ValidationGroup="DirectHire" ClientValidationFunction="ValidateCostCentCat"
ErrorMessage="Please select a Cost Centre Category from the drop down list provided.">!</asp:CustomValidator>

View 1 Replies

AJAX :: Using An UpdatePanel With Dependant Drop Down Lists?

May 13, 2010

was having some trouble setting up databound cascasding dropdownlists. As a workaround I decided to go down the route of placing three standard dropdownlists in an updatepanel - I cant find any info to help to do this.Can anyone help with what I need??? I need three dependant dropdown lists to refresh after selection of the parent one without refreshing the whole page. Im using VS2005 .net 2.0 and I have installed the ajax toolkit.

View 8 Replies

Web Forms :: Handle Lots Of Drop Down Lists On 1 Page?

Mar 22, 2011

I have a page that has a data grid and about 25 drop down lists.The datagrid displays Name and has an id col not visible. I was thinking that whan the user selects the select link button on the grid to then get all the data for all the ddl and populate the list and select the value or multiple values for that specific name that was selected. Thinking of it seems more like i should populate all the ddl and when a grid name is selected only get the keys for that specifc record and then mark the ddl items per that name. there are lots of ddl and lots of data, im not really sure the best way to proced. Any ideas appreciated.
I have a table with id typeId and Name that contains all of the data for the drop down list (different types of service providers , (plumbers, elec)I was thinking of selecting everything from that table and then in the page applying a filter by service provider type and using that to populate the ddls.

View 2 Replies

Web Forms :: Cascading Drop Down Lists From Single Table?

Oct 5, 2010

my one table consists of fields (id, flying from, flying to). thus i have one drop down for flying from and another drop down for flying to. i'm hoping to cascade them so 2nd drop down values are dependant on the values from 1st drop down. is it possible to do this using a single table? or must i use two tables and link the id's from both? and do i write anyting in the SelectedIndexChange event? the sqldatasource code looks like this:Flying From:

<asp:DropDownList ID="ddlFlyingFrom" runat="server" DataSourceID="SqlDataSource1"
DataTextField="FlyingFrom" DataValueField="Id" AutoPostBack="True" OnSelectedIndexChanged="ddlFlyingFrom_SelectedIndexChanged">

[code]...

View 11 Replies

How To Change The Appearance Of The Items Such As A The Text Boxes And Drop Down Lists

Feb 3, 2011

how i would go about creating the following page.

http://www.lifetick.com/app/#/createAccount//

Id just like to know how to change the appearance of the items such as a the text boxes and drop down lists. And is the the backgroud around the boxes an image?A link to how to do this would be useful if yous cant go into detail on how to do this.

View 4 Replies

Web Forms :: Trying To Fill 40 Drop Down Lists Dynamically By Appending The Suffix?

Jan 12, 2010

I have 40 Drop Down Lists that I want to fill using an XML file. Based on what is in the XML file i will add an item to a specific Drop down list. I don't want to manually loop thorugh each control by name. the ids for all of the controls start with DDLSession and then they have a suffix such as A2 or B4. What I want to do in the C# Code is ads items dynamically to the control like this:

[Code]....

View 2 Replies

Using 2 Drop Down Lists To Display Dress Size By Country Version?

Nov 20, 2010

I have a Dress Version Table with Colums UK, EU, USA.

Also a Dress Size table which has a VersionId Column corresponding to the Version Table

On my aspx, i have two drop down lists. DD1 is binded to an objectdatasource which

has a select Method to the DAL and retrives the 3 Verions.

DD2 has Get DressSize by Version Method with a Select Parameter which is the DD1 selected Value.

I have wrapped the above in an update panel and the full code is below.

This works but I wonder if there is a better way of doing this?? I also have a probem in that the Dropdowns are in a panel that is within a modal pop up extender. When the dropdowns post back the whole panel disappears. Not sure why??

Dress Size:

</p>
<asp:UpdatePanel ID="UpdatePanel2"
runat="server">
<ContentTemplate>

[Code]....

View 1 Replies

AJAX :: Populating A Series Of Cascading Drop Down Lists Through Code?

Aug 20, 2010

I am new to Ajax in general but I have a series of cascading drop down lists that are working fine. I'm using them on a form that I want to be able to either add a new row of data to the database or edit an existing one. I have the insert a new row working but editing an existing one is a bit trickier. The drop down lists are only part of the form but I would like to be able to query for a row id and set their values. Right now I'm querying for a row of data and populating the form with its values on page load and all of the fields work except for the drop down lists. I assume that this is because when the page is loading the web methods haven't run yet to populate the cascading drop downs. Therefore I can't set the selected value because there aren't any values yet. So therefore I'm pretty sure I need to do this from a web method so that it runs after the lists are populated or while the lists are populating but I don't know how.

View 3 Replies

Forms Data Controls :: Create A Placeholder For Drop Down Lists?

Aug 25, 2010

I'm using VWD with a database back end. I have a list of teams which are marked off by league, level, division, teamid and then using gridview for the list of players per teams.I've got the drop downs working correctly but running into a little snag and that is on the auto postback.When I only have one option come up in a list, i obviously don't change that list and thus it doesn't change the next drop down because there is no post back. is there a way to use a "header" value?

View 4 Replies

Forms Data Controls :: Pass A Value To The 2 Master / Detailed Drop Down Lists?

Oct 5, 2010

using below code, I bind 2 drop down lists.

[Code]....

And using the below code, I pass the content of a cell of GridView selectedRow to those DopDownLists .

[Code]....

But there is an error when I try to change the selected value of ddlCity (Detail)...What shall I do ?

View 5 Replies

Web Forms :: How To Bind Two Drop Down Lists In .Net In Visual Studio Using Formview Insert Template Using C#

Aug 9, 2010

I am using C#, Object Data Source, formview and a BLL. I have two drop down lists and two data sources. One populates the other. Drop down list #1 populates Drop Down list # 2 based on its selection . Drop down list # 1 is populated with DataSource #1. Forview is using DataSource #3 to send the ietms. When I add: SelectedValue='<%#Bind("Make_ID") %>', I get the error below:

Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control

I have seen a solution online but it is using LINQ and I am not familiar with it. I need to find the selected value of the drop down lists.

View 4 Replies

MVC :: Creating A Generic Template Writer That Can Handle Drop Downs And Option Lists?

Sep 20, 2010

If I have a the following model

[Code]....

And the following generic control template writer (which would have to be extended appropriately)

[Code]....

I would like to be able to add an attribute either builtin or something I create, such as

[Code]....

The generic template writer would then automatically create a Select box instead of a textbox for this item, and populate it with the list I have passed.

There may need to be another property set to have it write option boxes or radio buttons.

The question has two parts: (1) Is this an appropriate metaphor? and (2) Can you point me to an example that does this or to an appropriate metaphor.

What I want is a generic control writer that looks at the type of the object, writes the appropriate html, and a way to pass in external data for things like lists and enums.

View 3 Replies

Web Forms :: Make Up Dropdown Lists With Numbers ?

Mar 6, 2010

I want to know how to make up dropdown lists with numbers in them and and the end of the page as you selected the numbers they add themselfs up and you see a total at bottom the page

drop down list one 50

drop down list two 55

drop down list three 35

TOTAL IS _____140 _______

(and the end of the page when you select one number in each dropdown list) it adds it up for you and shows your total on the same page

View 2 Replies

Forms Data Controls :: DatagridView Postback / Cannot Make The Datagridview's Buttonfield Respond?

Feb 17, 2011

I am new to asp.net and was trying to use datagridview in my webform. I was able to bind it to my database but I cannot make the datagridview's buttonfield respond. It seems the grid's SelectedIndexChanged event is not being fired or has issues with postback. Even a very simple statement is not being executed by the program e.g.

protected void grid_SelectedIndexChanged(object sender, EventArgs e)
{
detailsLabel.Text = "asdfasdfsafasddf";
}

It seems the SelectedIndexChanged is not being fired. I have checked my IE and scripting is enabled.

I am using VS 2008 and IE7. Can anyone share a solution on how to solve this issue?

View 7 Replies

Forms Data Controls :: Develop A Custom Data-bound Control Which Will Contain, Few Text-boxes, Drop-down Lists And Labels?

Mar 24, 2010

I need to develop a custom data-bound control which will contain, few text-boxes, drop-down lists, labels, and other standard web-server controls. And, I want to be able to load this control from a web page on button click. When the user enters any data to any of its child controls, i should be able to save, and also retrieve when the data-bound control is loaded again. Also, the data in the child control should retain their value on postback. What approach should i follow?

View 7 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved