I have a gridview with multiple dropdownlist, textboxes on footer template and I wanted to add the values entered to the grid.
However, I have a condition where the second dropdownlist has to be loaded by based on what is selected in the first dropdownlist.
Is this possible? any examples would be greatly appreciated.
Have a look at this very good Example: Implementing Cascading DropDownList in ASP.NET GridView
And if you want an AJAX based method, take a look at: Ajax Cascading DropDownList With Database Example in GridView
Related
Suppose I have a e-shop web app. I have a product categories table in my database that populates a gridview using sqldatasource.
I want to be able to click on the select hyperlink on a row and use that event to populate ANOTHER gridview based on the ID of the product category that is clicked. E.g say the 'CDs' row is clicked, another gridview shows all the different CDs.
As a result, I need the select(sql) statement for the second table to be dynamic based on what the user clicks.
Has anyone done anything like this before?
Any help would be greatly appreciated,
Mark
It should be very easy. The key is to use SelectedValue of first Gridview to be used as a parameter to the query to populate second gridview.
Here is a sample: Master/Detail GridView
The sample show GV and DetailsView but in your case you replace DV with another GV.
I need list view, that supports column with check boxes. Please help me add column with check boxes to ListView or add paging to CheckboxList
EDIT: I've forgot that also I need data bounding.
I've found out IPagedItemContainer interface and DataPager class. I need to add interface implementation to CheckboxList.
For Listview I haven't found any ideas on adding column
Use GridView with unvisible Header Row. And add a Checkbox Column.
I've got a bit of an chicken and an egg.
I need to bind a gridview to a set of database values. The gridview is dynamic and the columns, cells are created at run time.
As such, I need to re-bind the grid on every postback in the pre-init, init events after very post back.
However, the data used to populate the grid uses a value from a dropdown box on the same page. As such, the value of dropdown is not accessible through viewstate until after the init event (i.e. the selected index is always the first item in the list until after on init).
How can I get access to the value of the drop down in time to rebind the grid before the pageload event?
If the Gridview always has the same number of columns, you could have the dynamic query generate column names as aliases, and then just rebind the Gridview on dropdown change?
you can use and HtmlHidden control for store the value you need. It doesn't depend by the viewstate and it's available into the page init
Currently in asp.net, we can have only one value in a ListItem in a DropDownList. However I hope I can:
<MultiValueDropDownList id="ddl" runat="server" />
ddl.Items.Add(new MultiValueListItem { Text="text", DBValue="db", EngineValue=1 });
var dbValue = ddl.SelectedItem.DBValue;
What I'm going to do is inherit DropDownList and ListItem. Do you guys have any better solutions?
[Closed]
At last I decide to choose a lazy way. Store the values in ListItem.Attributes. And using extension methods of DropDownList to help to get the collection of values. Thanks for your help!
See if this helps:
EasyListBox
How to display multi-column in ASP Dropdown List?
asp.net : an alternative to multi-column DropDownList Gridview within dropdownlist / combobox (using the Ajax DropDownExtender)
Edit:
You can not inherit from ListItem.
See why: Extending ASP.NET DropDownList
The best solution then is to store the values inside ListItem.Attributes.
I Have a page where there are two Dropdownlist and both have the same data in it but when user selects the value in Dropdownlist1 ,same value should be selected automatically in Dropdownlist2?
Thanks
Smartdev
You can do that a couple of ways. If you're using the built in asp.net postback approach then you can set the value of the dropdown box server side.
If you're wanting to do this on the front end you can use jQuery (or standard Javascript) to set the selectedIndex of the second dropdown.
I assume that's the kind of answer you are after and not just for someone to write the code for you. :)
so in your code behind OnSelectedIndexChanged, you need to rebind both DropDownList1 and DropDownList2 to the same datasource.