TrialUser
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
Please help. Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
<%@ Control Language="vb" AutoEventWireup="false" CodeBehind="ucPr.ascx.vb" Inherits="ucPr" %>
<link href="/Assets/Styles/Produ ct.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 ">
<Fields>
<asp:NextPreviousPagerFiel d FirstPageText="First" ShowFirstPageButton="True"
ShowNextPageButton="False" ShowPreviousPageButton="Tr ue" PreviousPageText = " <" />
<asp:NumericPagerField ButtonCount="5" />
<asp:NextPreviousPagerFiel d LastPageText="Last" ShowLastPageButton="True"
ShowNextPageButton="True" ShowPreviousPageButton="Fa lse" NextPageText=">" />
</Fields>
</asp:DataPager>
</div>
<asp:ListView ID ="lvProducts" runat="server" DataSourceID="odsProduct">
<LayoutTemplate>
<div class="divWrapperProduct">
<asp:PlaceHolder ID="itemPlaceHolder" runat="server"> </asp:PlaceHolder>
</div>
</LayoutTemplate>
<ItemTemplate>
<div class="divProduct">
<div style="float:left;width:90 px;height: 90px;borde r:2px solid #ccc;">
<img alt='Product' src='/Assets/Images/Produc ts/75/<%# DataBinder.Eval(Container. DataItem, "ImageFileName") %>'
style="vertical-align:midd le; margin-left:auto;margin-ri ght:auto;m argin-top: 10px;displ ay:block;m argin-top: 10px;" />
</div>
<a href='<%# DataBinder.Eval(Container. DataItem, "ProductURL")%>' style="margin-left:10px;fo nt-size:16 px #1D3A6C;font-weight:bold;" ><%# DataBinder.Eval(Container. DataItem, "ShortDesc")%> </a>
<hr style="color: #ccc;" />
<div>
<div style="margin-left:10px;fl oat:left;w idth:30%;" >
<span style="color:#58595B;font- size:12px; font-weigh t:bold;flo at:left;"> Item# : <%# DataBinder.Eval(Container. DataItem, "SKU")%></span>
<br />
<span style="color:#58595B;font- size:12px; font-weigh t:bold;flo at:left;"> Brand : <%# DataBinder.Eval(Container. DataItem, "BrndNm")%></span>
</div>
<div style="float:right;width:5 0%;margin: 10px;">
<span style="float:right;color: #58595B; font-size:13px;">
/ <%# DataBinder.Eval(Container. DataItem, "UM")%> </span>
<span style="margin-right:5px;fl oat:right; font-size:15px;font-weight :bold;colo r:#C4393E; ">
<%# String.Format("{0:c}", DataBinder.Eval(Container. DataItem, "YourPrice"))%>
</span>
</div>
<div style="float:right;width:5 0%;margin: 10px;">
<asp:ImageButton ID="imgTopAddtoCart" runat="server" ImageAlign="Right" ImageUrl="/Assets/Images/P roductDeta ils/ProdAd dCart.bmp" />
<asp:TextBox id="txtQty" runat="server" style="border:1px solid #ccc;width:25px;float:righ t;color:#5 8595B;font -weight:bo ld;margin- right:8px; margin-top :6px;">1</ asp:TextBo x>
<span style="color:#58595B;font- weight:bol d;float:ri ght;margin -top:6px;" >Qty:  ; </s pan>
</div>
</div>
</div>
</ItemTemplate>
<EmptyDataTemplate>
<div>
Search Returned No Results
</div>
</EmptyDataTemplate>
</asp:ListView>
<asp:ObjectDataSource ID="odsProduct" runat="server" SelectMethod="GetProducts"
SelectCountMethod="TotalRo wCount" EnablePaging="true" MaximumRowsParameterName=" pageSize"
StartRowIndexParameterName ="startRow Index" TypeName="ProductDataSourc e"
SortParameterName="sortExp ression">
<SelectParameters>
<asp:Parameter Name="startRowIndex" Type="Int32" />
<asp:Parameter Name="pageSize" Type="Int32" />
<asp:Parameter Name="sortExpression" Type="String" />
</SelectParameters>
</asp:ObjectDataSource>
</div>
<link href="/Assets/Styles/Produ
<div class="divProductResults">
<div class="divPager">
<asp:Label ID="lblCount" runat="server" ></asp:Label>
<asp:DataPager ID="dpProduct" runat="server" PageSize="10" PagedControlID="lvProducts
<Fields>
<asp:NextPreviousPagerFiel
ShowNextPageButton="False"
<asp:NumericPagerField ButtonCount="5" />
<asp:NextPreviousPagerFiel
ShowNextPageButton="True" ShowPreviousPageButton="Fa
</Fields>
</asp:DataPager>
</div>
<asp:ListView ID ="lvProducts" runat="server" DataSourceID="odsProduct">
<LayoutTemplate>
<div class="divWrapperProduct">
<asp:PlaceHolder ID="itemPlaceHolder" runat="server"> </asp:PlaceHolder>
</div>
</LayoutTemplate>
<ItemTemplate>
<div class="divProduct">
<div style="float:left;width:90
<img alt='Product' src='/Assets/Images/Produc
style="vertical-align:midd
</div>
<a href='<%# DataBinder.Eval(Container.
<hr style="color: #ccc;" />
<div>
<div style="margin-left:10px;fl
<span style="color:#58595B;font-
<br />
<span style="color:#58595B;font-
</div>
<div style="float:right;width:5
<span style="float:right;color: #58595B; font-size:13px;">
/ <%# DataBinder.Eval(Container.
<span style="margin-right:5px;fl
<%# String.Format("{0:c}", DataBinder.Eval(Container.
</span>
</div>
<div style="float:right;width:5
<asp:ImageButton ID="imgTopAddtoCart" runat="server" ImageAlign="Right" ImageUrl="/Assets/Images/P
<asp:TextBox id="txtQty" runat="server" style="border:1px solid #ccc;width:25px;float:righ
<span style="color:#58595B;font-
</div>
</div>
</div>
</ItemTemplate>
<EmptyDataTemplate>
<div>
Search Returned No Results
</div>
</EmptyDataTemplate>
</asp:ListView>
<asp:ObjectDataSource ID="odsProduct" runat="server" SelectMethod="GetProducts"
SelectCountMethod="TotalRo
StartRowIndexParameterName
SortParameterName="sortExp
<SelectParameters>
<asp:Parameter Name="startRowIndex" Type="Int32" />
<asp:Parameter Name="pageSize" Type="Int32" />
<asp:Parameter Name="sortExpression" Type="String" />
</SelectParameters>
</asp:ObjectDataSource>
</div>
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
lv.databind()
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
First of all set the AutoPostBack Property of dropDown to true..
Then.. in the SelectedIndexChaned event do this..
Ok Here is the code :
Then.. in the SelectedIndexChaned event do this..
Ok Here is the code :
protected void lvProducts_SelectedIndexChanged(object sender,EventArgs e)
{
// Your Code here..
}
ASKER