Click here to Skip to main content
15,896,207 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am working with autocompleteextender in gridview. I am getting key,value pair from webservice. When i am selecting item in textbox it is giving me the value which i got from webservice in alert. I need to assign this value to the hiddenfield which is in gridview. My code is as below. Can you please suggest me how can i do this?


ASP.NET
<script type="text/javascript" language="javascript">
function GetCode(source, eventArgs) {
    alert(eventArgs.get_value());
}</script>


<asp:GridView ID="gvEmpworkhour" runat="server" AutoGenerateColumns="False" 
                ShowFooter="True" CellPadding="4" ForeColor="#333333" GridLines="None" 
                  onrowdatabound="gvEmpworkhour_RowDataBound" 
                  onrowcommand="gvEmpworkhour_RowCommand">
                <rowstyle backcolor="#EFF3FB" />
                <columns>
 <asp:TemplateField HeaderText="EmployeeName" HeaderStyle-HorizontalAlign="Center">
                        <itemtemplate>
                           
                             <asp:UpdatePanel ID="upEmployeeName" runat="server">
                             <contenttemplate>
                              <asp:AutoCompleteExtender ID="AutoCompleteExtender1" runat="server" MinimumPrefixLength="1" ServiceMethod="showEmployee"
                                ServicePath="~/WebService.asmx" TargetControlID="txtEmployeeName" CompletionInterval="1000" EnableCaching="true"
 CompletionSetCount="20" 
CompletionListCssClass="AutoExtender"
             CompletionListItemCssClass="AutoExtenderList"
             CompletionListHighlightedItemCssClass ="AutoExtenderHighlight"
             CompletionListElementID="divwidth" OnClientItemSelected="GetCode"> 
                            
                            <asp:TextBox ID="txtEmployeeName" runat="server" AutoPostBack="true" OnTextChanged="txtEmployeeName_TextChanged"> 
                            
                            <asp:HiddenField ID="hidEmpID" runat="server" />
                            </contenttemplate>
                            
                        </itemtemplate>                    
</columns>
               <footerstyle backcolor="#507CD1" font-bold="True" forecolor="White" />
               <pagerstyle backcolor="#2461BF" forecolor="White" horizontalalign="Center" />
               <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
               <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
               <editrowstyle backcolor="#2461BF" />
               <alternatingrowstyle backcolor="White" />
Posted
Updated 20-Mar-13 1:06am
v3
Comments
kamalsekhar 4-Jan-14 9:45am    
Hi,
Can you send me complete code how u solve this AutoCompleteExtender. i m not able to solve

1 solution

you have textchanged event!. So why not to assign the textbox value to hiddenfield value?.
 
Share this answer
 
Comments
Mada Naga Sankar 20-Mar-13 7:25am    
It should be in javascript function "GetCode".Because it has large data in gridview. For every selection it shouldn't do postback.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900