Hi,
I have to provide a page with a dealer data-based sales report: it has a webdropdown (linked to an objectdatasource) that lists the dealers, and then two Webdatepickers: From and To Date.
Finally a button to get the report based on the 3 values selected in the wdd, and the 2 wdp's.
I have all this working, but I think it goes through a postback and so it flickers. I wanted to do it without a postback.
'So I mocked it up with Craig Shoemaker's bookrepository, to which I added a method to get a book by id.
Now I have two ods'es: one for the wdd, and one for the wdg. The problem is: I seem to not be able to bind the selectparameter for ods_wdg to the selected value of the wdd. So i have to use a helper control (TextBox) called wddSelectedLabel. Which I then set in a codebehind upon selectionchanged in the wdd. I first tried to set the value in javascript, and it sets the value, but it doesn't refresh the ods_wdg.... So how to bind the dropdown selectedvalue to the selectparameter of ods_wdg, so when you select a different value in the wdd, the ods_wdg will automatically refresh and show the details for the book selected in the wdd?
So here is my code sofar:
In Default.aspx:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="TesterCLR40.Default" %>
<%@ Register Assembly="Infragistics4.Web.v10.2, Version=10.2.20102.1011, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb" Namespace="Infragistics.Web.UI.ListControls" TagPrefix="ig" %>
<%@ Register assembly="Infragistics4.Web.v10.2, Version=10.2.20102.1011, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb" namespace="Infragistics.Web.UI" tagprefix="ig" %>
<%@ Register assembly="Infragistics4.Web.v10.2, Version=10.2.20102.1011, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb" namespace="Infragistics.Web.UI.GridControls" tagprefix="ig" %>
<%@ Register assembly="Infragistics4.WebUI.WebDataInput.v10.2, Version=10.2.20102.1011, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb" namespace="Infragistics.WebUI.WebDataInput" tagprefix="igtxt" %>
<!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 runat="server"> <title></title></head><body> <form id="form1" runat="server"> <asp:Label runat="server" ID="label99">ofishfsdh</asp:Label> <div> <br /><br />
<asp:UpdatePanel ID="ud" runat="server"> <ContentTemplate> <ig:WebScriptManager ID="wsm" EnablePageMethods="true" runat="server"> </ig:WebScriptManager> <br /> <asp:Label runat="server" Text="Here is the wdd (linked to ods_wdd):"></asp:Label> <ig:WebDropDown ID="wdd" runat="server" Width="200px" DataSourceID="ods_wdd" TextField="Title" ValueField="ID"> <DropDownItemBinding TextField="Title" ValueField="ID" /> <AutoPostBackFlags SelectionChanged="On" /> </ig:WebDropDown> <asp:Label Text="This is the textbox that helps transfer the wdd.selectedvalue to the ods_wdg:" runat="server" /> <asp:TextBox ID="wddSelectedLabel" runat="server" Text="6" /> <br /><br />
<asp:Label Text="And this is the wdg (linked to ods_wdg) that's supposed to show the details for the item selected in the wdd:" runat="server" /> <ig:WebDataGrid ID="wdg" runat="server" Height="350px" Width="400px" AutoGenerateColumns="False" DataSourceID="ods_wdg" > <Columns> <ig:BoundDataField DataFieldName="ID" Key="ID"> <Header Text="ID" /> </ig:BoundDataField> <ig:BoundDataField DataFieldName="Title" Key="Title"> <Header Text="Title" /> </ig:BoundDataField> <ig:BoundDataField DataFieldName="Author" Key="Author"> <Header Text="Author" /> </ig:BoundDataField> <ig:BoundDataField DataFieldName="Url" Key="Url"> <Header Text="Url" /> </ig:BoundDataField> <ig:BoundDataField DataFieldName="Price" Key="Price"> <Header Text="Price" /> </ig:BoundDataField> <ig:BoundDataField DataFieldName="PublishDate" Key="PublishDate"> <Header Text="PublishDate" /> </ig:BoundDataField> <ig:BoundDataField DataFieldName="PriceFormatted" Key="PriceFormatted"> <Header Text="PriceFormatted" /> </ig:BoundDataField> <ig:BoundDataField DataFieldName="PublishDateShort" Key="PublishDateShort"> <Header Text="PublishDateShort" /> </ig:BoundDataField> </Columns> </ig:WebDataGrid> <asp:ObjectDataSource ID="ods_wdd" runat="server" TypeName="BookRepository" SelectMethod="GetBooks" /> <asp:ObjectDataSource ID="ods_wdg" runat="server" TypeName="BookRepository" SelectMethod="GetByID" > <SelectParameters> <%--This is the select parameter, but I would like to have bound the select parameter to the wdd.selectedvalue--%> <asp:ControlParameter ControlID="wddSelectedLabel" Name="ID" PropertyName="Text" Type="Int32" /> </SelectParameters> </asp:ObjectDataSource> </ContentTemplate> </asp:UpdatePanel> </div> </form></body></html>
and default.aspx.cs
using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.Services;using System.Web.UI;using System.Web.UI.WebControls;using Infragistics.Web.UI.ListControls;
namespace TesterCLR40{ public partial class Default : System.Web.UI.Page {
protected override void OnInit(EventArgs e) { base.OnInit(e); this.wdd.SelectionChanged += new DropDownSelectionChangedEventHandler(wdd_SelectionChanged); }
void wdd_SelectionChanged(object sender, DropDownSelectionChangedEventArgs e) { this.wddSelectedLabel.Text = wdd.SelectedValue;
} protected void Page_Load(object sender, EventArgs e) { }
}}
Hello,
You can bind the WebDataGrid directly to the WebDropDown by setting the control name to the WebDropDown and the PropertyName to "SelectedValue" as follows.
<SelectParameters> <asp:ControlParameter ControlID="WebDropDown3" DefaultValue="15" Name="numberOfBooks" PropertyName="SelectedValue" Type="Int32" /> </SelectParameters>
The attached sample demontstrates this using the BookRepository.
Please let me know if you have any questions.
Thanks,Valerie
Please let me know if you have any other questions on this matter.
Thanks,
Valerie
Hi Valerie,
Yes, that worked great! thanks! Sorry, hadn't seen an email about it, and just checked the site and noted you answer. Once again, thanks very much Valerie!
I have another question: I want to create customer search webdropdown that I want to load on demand also based on an objectdatasource linked to an oracle sp. So as the user types it's supposed to call the sp and populate a new dropdown list. I have written the oracle stored procedure that returns 10 customers based on the searchstring that's typed in the dropdown. I've checked if I set the CurrentValue of the dropdown in the designer, it shows the results in the dropdown.
But when I start typing in the dropdown it doesn't update the results, even though it DOES call the stored procedure with the new string I am typing, and the stored procedure also returns a new datatable with new results. What am I doing wrong here?
Here is the webdropdown with the link to the objectdatasource:<ig:WebDropDown runat="server" ID="ddCustomerName" EnableAutoCompleteFirstMatch="false" Width="250px" DataSourceID="ods_ddCustomerName" EnableViewState="false" EnableAutoFiltering="Server" OnPreRender="ddCustomerName_PreRender" TextField="textField" DropDownContainerHeight="300px"></ig:WebDropDown>
Here is the objectdatasource which is kind of circular, because it is the datasource to the webdropdown, but the typed value in the dropdown is also the selectparameter to the sp.<asp:ObjectDataSource ID="ods_ddCustomerName" runat="server" SelectMethod="Oracle_Pkg_Web_DropDowns_getCustomerByNamePhone" TypeName="ETBossWeb.Customers.CustomerInformation" EnableCaching="False"><SelectParameters> <asp:ControlParameter ControlID="ddCustomerName" Name="searchString" PropertyName="CurrentValue" Type="String" /> </SelectParameters></asp:ObjectDataSource>
This is the codebhind that the webdatasource points to:[DataObjectMethod(DataObjectMethodType.Select, true)]public DataTable Oracle_Pkg_Web_DropDowns_getCustomerByNamePhone(string searchString){ return Oracle_Pkg_Web_DropDowns.Instance.getCustomerByNamePhone(searchString, User.Identity.Name);}
Finally for completion here is also the proc:procedure getCustomerByNamePhone( searchString_IN VARCHAR2 ,cur_IN_OUT IN OUT ref_cur ) as begin open cur_IN_OUT for with a as ( select customerid from esp_crm.customer_names where instr(name_plus_resource,upper(searchstring_IN)) > 0 and rownum <= 10 ) select b.contact || ' - ' || c."RESOURCE" as textfield ,a.customerid as valuefield from a join esp_crm_customer.crm_customers b on a.customerid = b.customerid join esp_crm_customer.crm_customers_resourcemb c on a.customerid = c.customerid ; end;end;/
Hi Alex,
You should handle the ItemsRequested server-side event in that case. I suggest you to look at these samples:
http://samples.infragistics.com/2010.2/WebFeatureBrowser/WebDropDown/WebDropDownCascade.aspx
http://samples.infragistics.com/2010.2/WebFeatureBrowser/WebDropDown/WebDropDownCascadeClient.aspx
Angel