开发者

Object Data Source not filtering my listview?

I'm trying to filter a listview, using a textbox control via an object datasource. However when I add anything nothing happens . I've created something similar before and all the codes pretty much the same. anyone got any ideas' what I'm missing ??

<asp:TextBox ID="namefilter" runat="server" />
    <asp:Button ID="button1" runat="server" />

    <asp:ListView DataSourceID="DataSource" ID="ListView1" runat="server" DataKeyNames="ID" InsertItemPosition="LastItem">
    <LayoutTemplate>

        <table cellspacing="1" cellpadding="1" border="0" bgcolor="#6699cc" width="100%" >
        <tr>
            <th>&nbsp;</th>
            <th>&nbsp;</th>
            <th><span class="Caption1">Name</span></th>
            <th><span class="Caption1">Phone</span></th>
        </tr>

        <tr id="itemPlaceholder" runat="server" />
        </table>

    </LayoutTemplate>

    <ItemTemplate>
        <tr style="background-color: White;" >
            <td><asp:LinkButton ID="btnEdit" runat="server" Text="Edit" CommandName="Edit" /></td>
            <td><asp:LinkButton ID="btnDelete" runat="server" Text="Delete" CommandName="Delete" /></td>
            <td align="center"><%# DataBinder.Eval(Container, "DataItem.Name")%>           </td>
            <td align="center"><%# DataBinder.Eval(Container, "DataItem.Phone")%>          </td>
        </tr>                                                                            
    </ItemTemplate>

    <EditItemTemplate>
        <tr style="background-color: White;" >
            <td><asp:LinkButton ID="btnSave" runat="server" Text="Save" CommandName="Update" /></td>
            <td><asp:LinkButton ID="btnCancel" runat="server" Text="Cancel" CommandName="Cancel" /></td>
            <td><asp:TextBox ID="EditName" runat="server" Text='<%# Bind("Name") %>' /></td>
            <td><asp:TextBox ID="EditPhone" runat="server" Text='<%# Bind("Phone") %>' /></td>
        </tr>                                                     
    </EditItemTemplate>
    <InsertItemTemplate>
        <tr bgcolor="#6699cc" >
            <td><asp:LinkButton ID="InsertButton" CommandName="Insert" runat="server" Text="Insert" ValidationGroup="add" CssClass="Caption1" /> </td>
            <td><asp:LinkButton ID="CancelButton" CommandName="Cancel" runat="server" Text="Cancel" CausesValidation="false" CssClass="Caption1" /></td>
            <td> <asp:TextBox ID="Insert开发者_JAVA技巧Name" runat="server" Text='<%# Bind("Name") %>' ValidationGroup="insert" /> </td>
            <td><asp:TextBox ID="InsertPhone" runat="server" Text='<%# Bind("Phone") %>' />  </td>
    </InsertItemTemplate>

</asp:ListView>


<asp:LinqDataSource 
        ContextTypeName="assembly" 
        EnableUpdate="true" 
        EnableDelete="true" 
        EnableInsert="true"
        ID="DataSource" 
        OrderBy="Email desc" 
        runat="server" 
        TableName="Contacts" 
        AutoSort="true" 
         >
<whereParameters> 
    <asp:ControlParameter ControlID="emailfilter" Name="Email" PropertyName="Text" Type="String" ConvertEmptyStringToNull="false"   />
</whereParameters>
</asp:LinqDataSource>


d'oh, forgot to add the sort by where clause in the linqdatasource.. 3 hours wasted!!!

   <asp:LinqDataSource 
        ContextTypeName="Immediacy.VS.Plugins.DBML.VisitScotlandDataContext" 
        EnableUpdate="true" 
        EnableDelete="true" 
        EnableInsert="true"
        ID="DataSource" 
        OrderBy="Email desc" 
        runat="server" 
        TableName="Contacts" 
        AutoSort="true" 
        Where='(@Email == null) || (Email == @Email)' 
         >
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜