我查询 列表里面只有一条信息 为什么页面会重复显示 2 条
程序代码:
<asp:TextBox ID="tb_doctor" runat="server" style=" height:20px; width:100px; float:left;" ></asp:TextBox> <asp:ImageButton runat="server" ImageUrl="img/1.png" Width="30px" Height="30px" onclick="Unnamed1_Click" /> <asp:DataList ID="DataList23" runat="server" RepeatDirection="Horizontal"> <ItemTemplate> <div style="width:auto; height:auto;"> <img ID="Image1" runat="server" src='<%#Bind("authorUrl")%> ' style=" height:150px;border:none; " /></a> </div> <div style="width:100%; height:100%; margin-top:10px;font-size:12px;float:left; text-align:center;"> <asp:Label ID="Label1" runat="server" Text='<%#Bind("AuthorName")%>'></asp:Label> 教授 </div> <div style="width:100%; height:100%; margin-top:10px;font-size:12px; float:left;text-align:center;">专业: <asp:Label ID="Label3" runat="server" Text='<%#Bind("AuthorSubject")%>'></asp:Label> </div> </ItemTemplate> </asp:DataList>
程序代码:
protected void Unnamed1_Click(object sender, ImageClickEventArgs e) { DataTable dt = author.servers(this.tb_doctor.Text); if (dt.Rows.Count == 0) { ClientScript.RegisterStartupScript(this.GetType(), "Error", "<script>alert('输入不正确,请重新输入!')</script>"); } this.tb_doctor.Text = ""; this.DataList23.DataSource = dt; this.DataList23.DataBind(); }
程序代码:
///<summsry> ///专家查询 ///AuthorName 专家名字 ///</summsry> public static DataTable selects(string AuthorName) { StringBuilder strsql = new StringBuilder(); strsql.Append("select AuthorName,authorUrl,AuthorSubject from authoritative "); if (!AuthorName.Equals("")) { strsql.AppendFormat("where AuthorName like '%" + AuthorName + "%' "); } return DBHelper.GetDataSet(strsql.ToString()); }