Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET Ajax
Hello Everyone,
 
Please tell me how to set the ContextKey of AutoCompleteExtender, i am tried but it will shows me a Error like this.
 
Compiler Error Message: CS0103: The name 'AutoCmpExt' does not exist in the current context
 
Source Error:
 

Line 453:         setContext = function ($this) {
Line 454:            $bdsType = $j($this).parents('tr').children('td:eq(6)').find('select').val();
Line 455:            $find('<%=AutoCmpExt.ClientID %>').set_contextKey($bdsType);
Line 456:         }
Line 457:      });
 
i used the Javascript to set ContextKey of AutoCompelteExtender like this.
 
$j(document).ready(function () {
         setContext = function ($this) {
            $bdsType = $j($this).parents('tr').children('td:eq(6)').find('select').val();
            $find('<%=AutoCmpExt.ClientID %>').set_contextKey($bdsType);
         }
      });
 
i used the AutoCompleteExtender inside the GridView. When i type in the textbox, the jquery code will find the 'select' Control on previous cell of the GridView and the selected value of that control as a ContextKey of AutoCompleteExtender. the GridView Source i provided the below.
 
<asp:GridView ID="gvLotAccept" runat="server" CellPadding="3" CellSpacing="0" GridLines="None"
                     AutoGenerateColumns="False" Font-Size="10pt" Font-Names="Verdana" PageSize="100"
                     AllowPaging="true" EmptyDataText="No Records Found" CssClass="grid_table" OnPageIndexChanging="gvIssue_PageIndexChanging"
                     OnRowDataBound="gvIssue_RowDataBound">
                     <Columns>
                        <asp:TemplateField HeaderText="S.No">
                           <ItemTemplate>
                              <%#(Convert.ToInt16(DataBinder.GetPropertyValue(Container, "DataItemIndex")) + 1) %>
                           </ItemTemplate>
                           <ItemStyle HorizontalAlign="center" Width="1%" VerticalAlign="middle" />
                           <HeaderStyle Width="25" CssClass="grid_header_top" HorizontalAlign="Left" />
                        </asp:TemplateField>
                        <asp:TemplateField ControlStyle-CssClass="grid_header_top" HeaderText="Select">
                           <ItemTemplate>
                              <input type="checkbox" runat="server" id="chk" value='<%#DataBinder.Eval(Container.DataItem, "Issue_Id") %>'
                                 onclick="return getEnableText(this)" />
                              <asp:HiddenField ID="hidLotNo" runat="server" Value='<%#DataBinder.Eval(Container.DataItem, "Lot_No") %>' />
                              <asp:HiddenField ID="hdnSortId" runat="server" Value='<%#DataBinder.Eval(Container.DataItem, "SortId") %>' />
                           </ItemTemplate>
                           <ItemStyle HorizontalAlign="center" Width="1%" VerticalAlign="middle" />
                           <HeaderStyle Width="25" CssClass="grid_header_top" HorizontalAlign="Left" />
                        </asp:TemplateField>
                        <asp:BoundField DataField="Lot_No" HeaderText="Lot No" HeaderStyle-HorizontalAlign="Left"
                           HeaderStyle-CssClass="grid_header_top" ItemStyle-HorizontalAlign="Right" />
                        <asp:BoundField DataField="SortCode" HeaderText="Sort Code" HeaderStyle-HorizontalAlign="Left"
                           HeaderStyle-CssClass="grid_header_top" ItemStyle-HorizontalAlign="Left" />
                        <asp:BoundField DataField="Issue_Dt" HeaderText="Issue Date" HeaderStyle-HorizontalAlign="Left"
                           HeaderStyle-CssClass="grid_header_top" ItemStyle-HorizontalAlign="Right" />
                        <asp:TemplateField HeaderText="Product Code">
                           <ItemTemplate>
                              <asp:DropDownList runat="server" ID="ddlProductCode" Enabled="false">
                              </asp:DropDownList>
                           </ItemTemplate>
                           <ItemStyle HorizontalAlign="center" Width="1%" VerticalAlign="middle" />
                           <HeaderStyle Width="25" CssClass="grid_header_top" HorizontalAlign="Left" />
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Type">
                           <ItemTemplate>
                              <asp:DropDownList runat="server" ID="ddlType" Enabled="false">
                                 <asp:ListItem Text="Select" Value="0"></asp:ListItem>
                                 <asp:ListItem Text="Border - SB" Value="3"></asp:ListItem>
                                 <asp:ListItem Text="Design - SD" Value="2"></asp:ListItem>
                                 <asp:ListItem Text="Shade - SS" Value="1"></asp:ListItem>
                              </asp:DropDownList>
                           </ItemTemplate>
                           <ItemStyle HorizontalAlign="center" Width="1%" VerticalAlign="middle" />
                           <HeaderStyle Width="25" CssClass="grid_header_top" HorizontalAlign="Left" />
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="B/D/S No">
                           <ItemTemplate>
                              <asp:TextBox runat="server" ID="txtBDSNo" Enabled="false" Style="width: 100px;" onkeyup="setContext(this);"></asp:TextBox>
                              <ajax:AutoCompleteExtender runat="server" ID="AutoCmpExt"
                                 TargetControlID="txtBDSNo" ServicePath="~/Services/ServiceAutoComplete.svc" ServiceMethod="GetBDSNo"
                                 OnClientItemSelected="fnGetBDS" MinimumPrefixLength="2" CompletionInterval="1000" UseContextKey="true"
                                 EnableCaching="true" CompletionSetCount="20" CompletionListCssClass="autocomplete_completionListElement"
                                 CompletionListItemCssClass="autocomplete_listItem" CompletionListHighlightedItemCssClass="autocomplete_highlightedListItem"
                                 DelimiterCharacters=";, :" ShowOnlyCurrentWordInCompletionListItem="true">
                              </ajax:AutoCompleteExtender>
                              <ajax:TextBoxWatermarkExtender ID="TextBoxWatermarkExtender1" runat="server" TargetControlID="txtBDSNo"
                                 WatermarkCssClass="autocomplete_Watermarktxt" WatermarkText="B/D/S Code">
                              </ajax:TextBoxWatermarkExtender>
                           </ItemTemplate>
                           <ItemStyle HorizontalAlign="center" Width="1%" VerticalAlign="middle" />
                           <HeaderStyle Width="25" CssClass="grid_header_top" HorizontalAlign="Left" />
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Supplier">
                           <ItemTemplate>
                              <asp:TextBox runat="server" ID="txtSupplier" Enabled="false" Style="width: 200px;"></asp:TextBox>
                           </ItemTemplate>
                           <ItemStyle HorizontalAlign="center" Width="1%" VerticalAlign="middle" />
                           <HeaderStyle Width="25" CssClass="grid_header_top" HorizontalAlign="Left" />
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Qty">
                           <ItemTemplate>
                              <asp:TextBox runat="server" ID="txtQty" Enabled="false" CssClass="sent" Style="width: 80px;"
                                 onkeypress="return prevent(this, event, 2)"></asp:TextBox>
                           </ItemTemplate>
                           <ItemStyle HorizontalAlign="center" Width="1%" VerticalAlign="middle" />
                           <HeaderStyle Width="25" CssClass="grid_header_top" HorizontalAlign="Left" />
                        </asp:TemplateField>
                     </Columns>
                     <EmptyDataRowStyle HorizontalAlign="Center" VerticalAlign="Top" />
                     <PagerStyle HorizontalAlign="Center" CssClass="paging_color" />
                     <AlternatingRowStyle CssClass="alt_color" />
                  </asp:GridView>
 
Please tell me any one how to find AutoCompleteExtender inside the GridView and set ContextKey
 
Thanks & Regards
Kanagaraj.M
Posted 2-Jul-12 22:16pm

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

I think you have to find first gridview & then try to find AutoCompleteExtender in gridview.
 
Plz go through this link
http://forums.asp.net/t/1581154.aspx
http://stackoverflow.com/questions/10625948/how-to-find-textbox-in-gridview-using-javascript-function-fired-on-onclientside
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 210
1 Richard MacCutchan 100
2 kbrandwijk 90
3 ProgramFOX 80
4 Mukesh Bhagat 65
0 Sergey Alexandrovich Kryukov 9,050
1 OriginalGriff 8,151
2 CPallini 2,613
3 Richard MacCutchan 2,221
4 Abhinav S 1,928


Advertise | Privacy | Mobile
Web02 | 2.8.140827.1 | Last Updated 3 Jul 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100