Problem with Object Datasource binding RRS feed

  • Question

  • User-583717446 posted

    Hi, I am finding it difficult to make this form working when i try to bind objectdatasource at run time i tried many ways but non worked my code is now messed up..  I have a simple web page with text box, drop down box, search button, gridview and object datasource.

    What i want user to search and show them the results..

    can some one give me a complete example using object datasource. I wan to make this application in 3-tier.

    i want to have Business Logic, Dataaccess in separate files and call them accordingly.

    My table cmpany details has many fields but i wan to dispaly only two in teh grd . Pleas hel me with the code

    SearchTest.aspx --code

        <table class="" width="100%">
            <tr align="center" valign="middle">
                    <table bgcolor="#81BE47" style="width: 500px" class="hor-search-table">
                            <td align="left" style="width: 33px">&nbsp;Search</td>
                            <td  style="width: 147px">
                                <asp:TextBox ID="txtSearchValue" CssClass="frm" runat="server" Width="188px" ></asp:TextBox>
                            <td style="width: 14px">
                            <td align="left" style="width: 100px">
                                <asp:DropDownList ID="ddSearchCategory" runat="server" Height="22px" Width="157px">
                                    <asp:ListItem Value="cmpKeywords">Keyword</asp:ListItem>
                                    <asp:ListItem Value="cmpCategory">Category</asp:ListItem>
                                    <asp:ListItem Value="cmpName">Company Name</asp:ListItem>
                            <td align="left">
                                <asp:Button ID="btnSearch" runat="server" Text="Search" Width="69px" />
                <td valign="top" height="5px">&nbsp;</td>
                <td align="center" valign="baseline">
                    <asp:GridView ID="gvBusDir" runat="server" AllowPaging="True" 
                        AllowSorting="True" AutoGenerateColumns="False" BackColor="White" 
                        BorderColor="#ADE147" BorderStyle="None" BorderWidth="1px" CellPadding="4" 
                        DataSourceID="odsSearchBusDir" PageSize="25"  
                        ForeColor="Black" GridLines="Horizontal" CssClass="hor-minimalist-b">
                            <asp:BoundField DataField="cmpName" HeaderText="Company Name" 
                                SortExpression="cmpName" />
                            <asp:BoundField DataField="cmpCategory" HeaderText="Category" 
                                SortExpression="cmpCategory" />
                        <FooterStyle  BackColor="#81be47" ForeColor="white" />
                        <HeaderStyle BackColor="#81be47" Font-Bold="True" ForeColor="White" />
                <PagerStyle BackColor="#81be47" ForeColor="white" HorizontalAlign="Center" Height="15px" BorderWidth="0" CssClass="hor-minimalist-paging" />
                        <SelectedRowStyle BackColor="#CC3333" Font-Bold="True" ForeColor="White" />
                    <asp:ObjectDataSource ID="odsSearchBusDir" runat="server" 
                        SelectMethod="GetSearchDetails2" TypeName="clsBusinessDir">
                            <asp:FormParameter FormField="ddSearchCategory" Name="vFieldName" 
                                Type="String" />
                            <asp:FormParameter FormField="txtSearchValue" Name="vSearchVale" 
                                Type="String" />

    Friday, April 15, 2011 3:56 PM


All replies