我想在gridview中具有自动完成功能,但是无法访问datagridView中的选择。
找不到selReferenceFooter,这是为什么。谢谢您的帮助。
前端代码。
<asp:TemplateField HeaderText="Referencia" SortExpression="referencia">
<ItemTemplate>
<asp:Label HtmlEncode="false" ID="lblReference" CssClass="gridTextbox" Text='<%# Eval("referencia") %>' runat="server" />
</ItemTemplate>
<%--<EditItemTemplate>
<asp:TextBox CssClass="gridTextbox" ID="txtReference" Text='<%# Eval("referencia") %>' runat="server" />
</EditItemTemplate>--%>
<FooterTemplate>
<asp:TextBox CssClass="gridTextbox" ID="txtReferenceFooter" runat="server" />
<select class="searchList" id="selReferenceFooter" runat="server"></select>
</FooterTemplate>
</asp:TemplateField>
后端代码。
void PopulateGridview(string queryStr)
{
using (MySqlConnection conn = new MySql.Data.MySqlClient.MySqlConnection(connString))
using (MySqlCommand cmd = new MySql.Data.MySqlClient.MySqlCommand(queryStr, conn))
{
conn.Open();
cmd.ExecuteNonQuery();
using (MySqlDataAdapter sda = new MySqlDataAdapter(cmd))
{
sda.SelectCommand = cmd;
sda.Fill(dt);
selReferenceFooter.DataSource = dt;
selReferenceFooter.DataTextField = "armario";
selReferenceFooter.DataValueField = "armario";
selReferenceFooter.DataBind();
selReferenceFooter.Items.Add("");
selReferenceFooter.Items.FindByText("").Selected = true;
}
}
}