Ebikeneser
Ebikeneser

Reputation: 2364

Update DataList with textBox input

I have the following textBox -

 <asp:TextBox ID="TextBox1" runat="server" AutoPostBack="true"></asp:TextBox>

 <asp:AutoCompleteExtender ID="AutoCompleteExtender1" runat="server"
 MinimumPrefixLength="1" ServiceMethod="PRETURN" ServicePath="WebService1.asmx"     
 TargetControlID="TextBox1"> </asp:AutoCompleteExtender>

When a user types into TextBox1 this sends a request to WebService1.asmx and calls the PRETURN service method. So as a user is typing the textBox brings a drop down list of strings that start with the letters the user is typing.

I now have the following DataList -

<asp:DataList runat="server" ID="pTextBox" >

<ItemTemplate>

<asp:CheckBox ID="CheckBoxPN" runat="server"  Checked='false' OnCheckedChanged="CheckBoxPN_CheckedChanged" AutoPostBack="true" />
<asp:TextBox ID="profileTextBox" runat="server" Text='<%# Container.DataItem.ToString() %>'></asp:TextBox>

</ItemTemplate>
</asp:DataList>

Where on Page_Load -

WebService1 ws = new WebService1();
pTextBox.DataSource = ws.Method();
pTextBox.DataBind();

My problem is I want to combine the functionality of the textBox with the DataList. So that when a user types into the textBox, instead of the textBox having a dropdown list, the rows in the DataList are updated. So for instance, if Text in the profileTextBox did not contain the prefix text in TextBox1 when the user was typing, it would disappear. Leaving the user with a list of rows relevant to their search. How can I achieve this?

Upvotes: 1

Views: 1117

Answers (1)

Brian Mains
Brian Mains

Reputation: 50728

Others have done something similar to the GridView control, using JQuery to show/hide rows depending on the filter criteria. One solution, which should be easily adaptable to the DataList, is available here.

Upvotes: 1

Related Questions