locked
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>
                <td>
                    &nbsp;</td>
            </tr>
            <tr align="center" valign="middle">
                <td>
                    <table bgcolor="#81BE47" style="width: 500px" class="hor-search-table">
                        <tr>
                            <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>
                            <td style="width: 14px">
                                by</td>
                            <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>
                                </asp:DropDownList>
                            </td>
                            <td align="left">
                                <asp:Button ID="btnSearch" runat="server" Text="Search" Width="69px" />
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
            <tr>
                <td valign="top" height="5px">&nbsp;</td>
            </tr>
            <tr>
                <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">
                        <Columns>
                            <asp:BoundField DataField="cmpName" HeaderText="Company Name" 
                                SortExpression="cmpName" />
                            <asp:BoundField DataField="cmpCategory" HeaderText="Category" 
                                SortExpression="cmpCategory" />
                        </Columns>
                        <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:GridView>
    
    
    
                    <asp:ObjectDataSource ID="odsSearchBusDir" runat="server" 
                        SelectMethod="GetSearchDetails2" TypeName="clsBusinessDir">
                        <SelectParameters>
                            <asp:FormParameter FormField="ddSearchCategory" Name="vFieldName" 
                                Type="String" />
                            <asp:FormParameter FormField="txtSearchValue" Name="vSearchVale" 
                                Type="String" />
                        </SelectParameters>
                    </asp:ObjectDataSource>
    
    
                </td>
            </tr>
        </table>

    Friday, April 15, 2011 3:56 PM

Answers

All replies