Link to home
Start Free TrialLog in
Avatar of TrialUser
TrialUserFlag for Afghanistan

asked on

Objectdatasource onselecting event

In my web page user enters some text and clicks a button. On this button click, I call a SQL server stored procedure. I am now moving to an object datasource.  After creating the object datasource, listview and the business object to support the object datasource, I am wondering how the Onselecting event is trigerred. HOw do I bind data?

Please help. Thanks
Avatar of starlite551
Flag of India image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of TrialUser


ok, I will try to rip off relevant code and post it in a bit. Thanks
<%@ Control Language="vb" AutoEventWireup="false" CodeBehind="ucPr.ascx.vb" Inherits="ucPr" %>
<link href="/Assets/Styles/Product.css" rel="stylesheet" type="text/css" />        
<div class="divProductResults">
                        <div class="divPager">              
              <asp:Label ID="lblCount" runat="server" ></asp:Label>
              <asp:DataPager ID="dpProduct" runat="server"  PageSize="10" PagedControlID="lvProducts">
               <asp:NextPreviousPagerField FirstPageText="First" ShowFirstPageButton="True"
             ShowNextPageButton="False" ShowPreviousPageButton="True" PreviousPageText = " <"  />
              <asp:NumericPagerField  ButtonCount="5" />
              <asp:NextPreviousPagerField LastPageText="Last" ShowLastPageButton="True"
             ShowNextPageButton="True" ShowPreviousPageButton="False" NextPageText=">" />
                      <asp:ListView ID ="lvProducts" runat="server" DataSourceID="odsProduct">
                        <div class="divWrapperProduct">
                            <asp:PlaceHolder ID="itemPlaceHolder" runat="server">  </asp:PlaceHolder>
                                 <div class="divProduct">
                                    <div style="float:left;width:90px;height:90px;border:2px solid #ccc;">
                                    <img alt='Product' src='/Assets/Images/Products/75/<%# DataBinder.Eval(Container.DataItem, "ImageFileName")  %>'
                                    style="vertical-align:middle; margin-left:auto;margin-right:auto;margin-top:10px;display:block;margin-top:10px;" />
                                    <a href='<%# DataBinder.Eval(Container.DataItem, "ProductURL")%>' style="margin-left:10px;font-size:16px #1D3A6C;font-weight:bold;" ><%# DataBinder.Eval(Container.DataItem, "ShortDesc")%>      </a>
                                    <hr style="color: #ccc;" />
                                        <div style="margin-left:10px;float:left;width:30%;">
                                            <span style="color:#58595B;font-size:12px;font-weight:bold;float:left;">Item# : <%# DataBinder.Eval(Container.DataItem, "SKU")%></span>
                                            <br />  
                                            <span style="color:#58595B;font-size:12px;font-weight:bold;float:left;">Brand : <%# DataBinder.Eval(Container.DataItem, "BrndNm")%></span>

                                             <div style="float:right;width:50%;margin:10px;">
                                               <span style="float:right;color: #58595B; font-size:13px;">
                                             / <%# DataBinder.Eval(Container.DataItem, "UM")%> </span>
                                             <span style="margin-right:5px;float:right; font-size:15px;font-weight:bold;color:#C4393E;">
                                           <%# String.Format("{0:c}", DataBinder.Eval(Container.DataItem, "YourPrice"))%>                                                                                  
                                           <div style="float:right;width:50%;margin:10px;">
                                            <asp:ImageButton  ID="imgTopAddtoCart" runat="server" ImageAlign="Right" ImageUrl="/Assets/Images/ProductDetails/ProdAddCart.bmp" />                                                  
                                             <asp:TextBox id="txtQty" runat="server" style="border:1px solid #ccc;width:25px;float:right;color:#58595B;font-weight:bold;margin-right:8px;margin-top:6px;">1</asp:TextBox>
                                             <span style="color:#58595B;font-weight:bold;float:right;margin-top:6px;">Qty:&nbsp;&nbsp;</span>    
                            Search Returned No Results

                 <asp:ObjectDataSource ID="odsProduct" runat="server" SelectMethod="GetProducts"
        SelectCountMethod="TotalRowCount" EnablePaging="true" MaximumRowsParameterName="pageSize"
        StartRowIndexParameterName="startRowIndex" TypeName="ProductDataSource"
            <asp:Parameter Name="startRowIndex" Type="Int32" />
            <asp:Parameter Name="pageSize" Type="Int32" />
            <asp:Parameter Name="sortExpression" Type="String" />
I have attached the code for the list view , object datasource and data pager client side creation. Then in my Header.Master I have a texbox for search text and a btnSearch button. when the user clicks on the search button, I want to call the stored procedure. When I do not have the object datasource I just do something like 
on btnSearch click I get dsProducts, then :

lvProducts.datasource = dtProducts

Now, I want to know how and when the communication happens between the business object and DAL to call this stored procedure. Please help thanks

Open in new window

First of all set the AutoPostBack Property of dropDown to true..
Then.. in the SelectedIndexChaned event do this..

Ok Here is the code :
protected void lvProducts_SelectedIndexChanged(object sender,EventArgs e)
    // Your Code here..

Open in new window