在asp.net中使用自定义过滤器的转发器 [英] repeater with custom filters in asp.net

查看:88
本文介绍了在asp.net中使用自定义过滤器的转发器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有转发器控件,其中我从sql server数据库绑定数据,现在我有多个记录显示在我的页面上,但我想我可以根据所选的下拉列表过滤我的记录。我需要4-5个下拉控件,这取决于我的需要,我不希望我的页面在过滤时刷新。

下面是示例,这个网站也使用复选框但我只需要下拉.. 。

http://www.phonearena.com/phones/full#/phones/full/



给我任何想法如何开始,我认为ajax是我需要的东西。如果有的话,建议一些例子。

I have repeater control in which i am binding data from sql server database, Now i have number of records showing on my page but i want that i can filter my records according to dropdown selected. I need 4-5 dropdowns control thats depend on my need and i don't want my page to refresh while filtering.
Below is the example, this website using checkboxes too but i need only dropdowns...
http://www.phonearena.com/phones/full#/phones/full/

Give me any idea how to start, i think ajax is the thing i need. Suggest some examples if you have.

推荐答案

是的,你对ajax有了确切的想法。通过使用updatepanel来停止刷新浏览器。它会帮助你
Yes,u got the exact idea about ajax. Go through uses of updatepanel where it stops the refresh of browser. It will help you


最好,如果你创建一个web用户控件,你可以在转发器中放置你想要的所有控件,而你创建web用户控件使用Updatel Panel同时,它会帮助你,而不是刷新每个选定项目的页面。



例如:用户控制的代码;



It will be best, if u create one web user control in which u can put all that control u want in a repeater, while u create web user control use Updatel Panel as well, it will help u, not to refresh the page on every selected item.

eg: code for web user control;

<![CDATA[<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="SubChemicals.ascx.cs" Inherits="ChemicalApp.SubChemicals" %>]]>



<asp:updatepanel id="UpdatePanel1" runat="server" xmlns:asp="#unknown">
<contenttemplate>
<table>
<tr>
<td valign="top">
    <asp:dropdownlist id="ddlchemicals" width="200px" runat="server" font-bold="False">
        AutoPostBack="True" 
        onselectedindexchanged="ddlchemicals_SelectedIndexChanged" Height="25px">
    </asp:dropdownlist>
</td>
<td valign="top">
    <asp:textbox id="txtdescription" runat="server" width="300px" font-bold="False">
        TextMode="MultiLine" Height="25px"></asp:textbox>
</td>
<td valign="top">
    <asp:textbox id="txtconc" runat="server" width="150px" font-bold="False">
        AutoPostBack="True" ontextchanged="txtconc_TextChanged" Height="25px"></asp:textbox>
</td>
<td valign="top">
    <asp:textbox id="txtunit" runat="server" width="150px" font-bold="False">
        Height="25px"></asp:textbox>
</td>
<td valign="top">
    <asp:textbox id="txtamt" runat="server" width="150px" font-bold="true"></asp:textbox>
</td>
</tr>
</table>
</contenttemplate>
<triggers>
<asp:asyncpostbacktrigger controlid="ddlchemicals" />
<asp:asyncpostbacktrigger controlid="txtconc" />
</triggers>
</asp:updatepanel>





Web用户控件的CodeBehind,即.cs文件,用于下拉列表OnSelectedEventChanged:





CodeBehind of web user control, i.e., .cs file, for dropdownlist OnSelectedEventChanged:

public void ddlchemicals_SelectedIndexChanged(object sender, EventArgs e)
        {
            int recid = Convert.ToInt32(ddlchemicals.SelectedValue);
            DataTable dt = new DataTable();
            dt = bl.GetSelectedSubChemicals(recid);
            txtdescription.Text = dt.Rows[0]["Descriptions"].ToString();
            txtunit.Text = dt.Rows[0]["Units"].ToString();
            dt = null;
        }
//u have to make this event as public





只需拖动这个网页用户控件在你的.aspx页面上,然后放入你的中继器。



希望这会有所帮助。



祝你好运



Just drag n drop this web user control on ur .aspx page, n then put in ur repeater.

Hope this will help.

Good Luck


这篇关于在asp.net中使用自定义过滤器的转发器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆