I have a WebDataGrid where the first field uses a dropdown provider. Whenever the user selects an item from the dropdown, I need to automatically select an item in another dropdown field and set 2 other fields, depending on what was selected. I need to be able to get a record from the database for the selected item to determine what the other fields should be. Is there a way to call a server method when the user selects from a dropdown where I can determine what was selected and be able to set the other fields? If not, what is the best way to accomplish this?
Thanks,
Jeff
This is not what I need. I want to set the selected item in the list, not filter the list. Also, I need the values set when the selection of the parent cell has changed, not when the user enters the child cell. When selecting an item from the parent, I need to change the selected item in a dropdown in another cell and set the value of 2 other fields that are text fields. In the ItemsRequest server method, I tried the following:
WebDropDown wdr = (WebDropDown)sender; wdr.Items.Clear(); dsProjects.SelectCommand = "SELECT [ProjectID], [ProjectName] FROM [Projects]"; wdr.TextField = "ProjectName"; wdr.ValueField = "ProjectID"; wdr.DataBind(); wdr.SelectedItemIndex = 3;
This did not work as the selected item was not changed.
Hello Jeff,
Yes, you can set multiple dropdown I would recommend you to handle EnteredEditMode event CellEditing event and call loadItems method based on the text of the cell text of the parent cell as shown below:
function loadDropDownItems(sender, args) {
var previousCell = args._cell._row.get_cell(args._cell.get_index() - 1);
if (args._editor._id == 'WebDataGrid1_provider2') {
args._editor.loadItems(previousCell.get_text());
}
if(args.getCell().get_index()==3)
{
var previousCell1 = args._cell._row.get_cell(args._cell.get_index() - 2);
if (args._editor._id == 'WebDataGrid1_provider3') {
args._editor.loadItems(previousCell1.get_text());
I hope this helps.
When I tried this, the dropdown list for every row was changed to only contain. I only want the dropdown in the current row to be changed. Also, I do would prefer to only set the selected item in the list, not filter the list.
Your example only sets one field. What I need to do is set 3 fields when an item in the dropdown is selected. Two of these are text fields and the other is a dropdown. Can I get the editor of the 3 fields following the dropdown filed so that I can set their values?
I have attached a markup and code behind that implements this functionality. You can specify Item requeted event for the cascaded dropDownprovider as shown below:
<EditorControl DropDownContainerMaxHeight="200px" EnableAnimations="False" runat="server" ID="provider2" OnItemsRequested="eProvider_ItemsRequested" DropDownContainerWidth="180" EnableDropDownAsChild="False"> <Button AltText="" /> </EditorControl>
You can access Editor Control programmatically and handle OnItemsRequested at runtime also. In the attached sample the “Description” column will populate its values based on the “CatagoryName” column dropdown editor.
I am not sure how to use the example with a DropDownProvider. How do you specify the ItemsRequested server-side event for the DropDownProvider? Also, I want to set the selected item for one row. Using the example, it would just change the items in the list and it would be for all rows.