Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
105
Using WebDropDown/WebDatePicker selected value as selectparameter for ObjectDataSource
posted

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)
        {
        }

    }
}