首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在Repeater中搜索

在Repeater中搜索
EN

Stack Overflow用户
提问于 2013-10-18 11:52:29
回答 1查看 47关注 0票数 0

在页面加载时,我想要显示repeater control中的所有字段,在文本框中输入licenseid时,我想显示特定的licenceid详细信息。

如果我把下面的代码放在中继器的数据源中,第一个就不能工作了。在第二个示例中,我放置了一个textbox,并在页面加载时将其值设置为0。它起作用了。但我希望两者都能正常工作。

代码语言:javascript
复制
 SELECT * FROM License WHERE (0 = @selectAll OR LicenseID=@LicenseID) -> Not working 

 SELECT * FROM License WHERE (0 = @selectAll ) ->working

 SELECT * FROM License WHERE (LicenseID=@LicenseID)-> working

绑定代码

代码语言:javascript
复制
 Protected Sub BindRepeater()

    Dim cmd As New SqlCommand("Select * from License", con)

    If con.State = ConnectionState.Closed Then

        con.Open()

     End If

     Dim ds As New DataSet()

     Dim adp As New SqlDataAdapter(cmd)

     adp.Fill(ds)



     Repeater1.DataBind()

     con.Close()

 End Sub
EN

回答 1

Stack Overflow用户

发布于 2013-10-18 15:05:18

代码语言:javascript
复制
Protected Sub BindRepeater(int licenseID)

string qry = "Select * from License WHERE 1=1";
if(licenseID>0) qry += " AND LicenseID=" + licenseID.ToString();

Dim cmd As New SqlCommand(qry, con)

If con.State = ConnectionState.Closed Then

    con.Open()

 End If

 Dim ds As New DataSet()

 Dim adp As New SqlDataAdapter(cmd)

 adp.Fill(ds)



 Repeater1.DataBind()

 con.Close()

结束子对象

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/19441287

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档