在下拉列表中显示文本框值
我有一个gridview,在gridview标题中我有两个控件文本框和下拉列表。
i想要在textbox中键入一些值,如果value在dropdown中则显示该值,否则为no。我试过,但我没有得到gridview控件id。但我尝试了一个演示,当我在gridview文本中键入然后该值显示在gridview外的下拉列表。但我不知道为什么它没有发生与gridview下拉菜单。
我的尝试:
I have one gridview,in gridview header I have two controls textbox and dropdown.
i want that I want to type some value in textbox if value is in dropdown then its show that value otherwise no.i have tried but i am not getting gridview control id.but i hv tried one demo that while i am typing in gridview text then that value is showing in dropdown which is outside of gridview.but i don't know why its not happening with gridview dropdown.
What I have tried:
<Columns>
<asp:TemplateField HeaderText="code" SortExpression="code" >
<ItemTemplate>
<asp:Label ID="Labelid" runat="server" Text='<%# Eval("code") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Name" SortExpression="name">
<HeaderTemplate>
<table>
<tr>
<td>
UserName
<asp:Button ID="Buttonname" runat="server" Text="▼" Height="15px" OnClick="Buttonnameclick"/>
</td>
</tr>
<tr>
<asp:DropDownList ID="DropDownListname" runat="server">
<asp:ListItem>Pragya</asp:ListItem>
<asp:ListItem>a</asp:ListItem>
<asp:ListItem>Priyanka</asp:ListItem>
<asp:ListItem>hema</asp:ListItem>
<asp:ListItem>Shiv</asp:ListItem>
</asp:DropDownList>
<asp:TextBox ID="TextBoxname" runat="server" OnTextChanged="nametextfilter" AutoPostBack="true" AutoCompleteType="Search" onkeyup="sync(this)" ></asp:TextBox>
</div>
</td>
</tr>
</table>
</HeaderTemplate>
我的查询
函数同步(文本框){
document.getElementById('<%= DropDownList1.ClientID %GT; ')。value = textbox.value;
var GridView = document.getElementById('<%= GridView1emp
for(var i = 0;我< 1; i ++){
var txtAmountReceive = $(input [id * = DropDownListname]);
txtAmountReceive.value = textbox.value;
}
My query
function sync(textbox) {
document.getElementById('<%=DropDownList1.ClientID %>').value = textbox.value;
var GridView = document.getElementById('<%=GridView1emp
for ( var i = 0; i < 1; i++) {
var txtAmountReceive = $("input[id*=DropDownListname]");
txtAmountReceive.value = textbox.value;
}
(input [id * = DropDownListname]);
txtAmountReceive.value = textbox.value;
}
("input[id*=DropDownListname]");
txtAmountReceive.value = textbox.value;
}
问题是当你一天
The problem is that when you day
(input [id * = DropDownListname] ); ,它将选择ID中的所有下拉列表。
您正在尝试设置值,但它无法设置,因为该选择器选择了多个元素。
("input[id*=DropDownListname]");, it will select all th dropdowns with that in the id.
The you are trying to set the value, but it can't set because there are multiple elements selected by that selector.