在页面加载时,我想要显示repeater control中的所有字段,在文本框中输入licenseid时,我想显示特定的licenceid详细信息。
如果我把下面的代码放在中继器的数据源中,第一个就不能工作了。在第二个示例中,我放置了一个textbox,并在页面加载时将其值设置为0。它起作用了。但我希望两者都能正常工作。
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绑定代码
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发布于 2013-10-18 15:05:18
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()结束子对象
https://stackoverflow.com/questions/19441287
复制相似问题