gridview isue中的AutoCompleteExtender [英] AutoCompleteExtender inside gridview isue

查看:76
本文介绍了gridview isue中的AutoCompleteExtender的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个gridview。我在gridview中使用AutoCompleteExtender。我在gridview中添加和删除按钮。当我添加第二行AutoCompleteExtender不工作。



< asp:GridView ID =grdItemsrunat =serverAutoGenerateColumns =FalseFont-Names = Arial

ClientIDMode =静态CssClass =表table-striped table-bordered table-hoverWidth =100%

字体大小=11pt AlternatingRowStyle-BackColor =#C2D69BHeaderStyle-BackColor =greenAllowPaging =TrueShowFooter =TrueOnRowCommand =grdItems_RowCommand

DataKeyNames =RowId>

< columns> < asp:TemplateField HeaderText =ItemName>

< itemtemplate>

< asp:TextBox ID =txtItemrunat =serverCssClass = form-controlOnTextChanged =txtItem_TextChangedAutoPostBack =true

text ='<%#Bind(ItemName)%>'autocomplete =offTabIndex =1> ;

< asp:HiddenField ID =txtItemIdrunat =serverValue ='<%#Bind(ItemId)%>'/>

< asp:AutoCompleteExtender ID =AutoCompleteExtender1runat =serverBehaviorID =AutoCompleteEx

TargetControlID =txtItemServicePath =../../ WebServices / AutoComplete.asmx ServiceMethod =GetItems
MinimumPrefixLength =1CompletionInterval =200EnableCaching =trueCompletionSetCount =20

DelimiterCharacters =;,:ShowOnlyCurrentWordInCompletionListItem =trueCompletionListCssClass =autocomplete_completionListElement

CompletionListItemCssClass =autocomplete_listItemCompletionListHighlightedItemCssClass =autocomplete_highlightedListItem>

< animations>

< onshow>

< sequence>

<% - 使完成列表透明a然后显示它 - %>

< opacityaction opacity =0>

< hideaction visible =true>



<% - 第一次缓存完成列表的原始大小

播放动画然后将其设置为零 - %>

< ScriptAction Script =

//缓存大小并设置初始大小

var behavior = $ find('AutoCompleteEx');

if(!behavior._height){

var target = behavior.get_completionList();

behavior._height = target.offsetHeight - 2;

target.style.height ='0px';

}/>

<% - 在淡入时从0px扩展到适当的大小 - %> ;

< parallel duration =。4>

< fadein>

< length propertykey =heightstartvalue = 0endvaluescript =$ find('Aut oCompleteEx')._ height>







< onhide>

<% - 折扣为0px并淡出 - %>

< parallel duration =。4>

< fadeout> < length propertykey =heightstartvaluescript =$ find('AutoCompleteEx')._ heightendvalue =0>







< HeaderStyle Font-Bold =true字体名称=Tahoma字体大小=12px宽度=35%BackColor =# 8DC894

ForeColor =GreenHorizo​​ntalAlign =Left/>

< itemstyle horizo​​ntalalign =Left>

< ; asp:TemplateField>

< itemtemplate>

< asp:Button ID =btnAddNewRowToolTip =Add New ContractCommandArgument =RowId
CommandName =AddCssClass =GridAddbtnrunat =server/>

< asp:Button ID =btnDeleteToolTip =DeleteCommandArgument =RowId CommandName =删除CssClass =GridDeletebtn运行at =server/>



< HeaderStyle Font-Bold =trueFont-Names =TahomaFont-Size =12pxWidth = 5%BackColor =#8DC894ForeColor =GreenHorizo​​ntalAlign =Left/>

< itemstyle horizo​​ntalalign =Right>

< ; alternatingrowstyle backcolor =#C2D69B>

< HeaderStyle BackColor =Green>< / HeaderStyle>

解决方案

find('AutoCompleteEx');

if(!behavior._height){

var target = behavior.get_completionList();

行为。 _height = target.offset高度 - 2;

target.style.height ='0px';

}/>

<% - 从在淡入时0px到适当的大小 - %>

< parallel duration =。4>

< fadein>

&l t; length propertykey =heightstartvalue =0endvaluescript =


find('AutoCompleteEx')._ height>







< onhide>

<% - 折扣为0px并淡出 - %>

< parallel duration =。4>

< fadeout>< length propertykey =heightstartvalue script =


find('AutoCompleteEx')._ heightendvalue =0>







< HeaderStyle Font-Bold =true字体名称=Tahoma字体大小=12px宽度=35%BackColor =#8DC894

ForeColor =GreenHorizo​​ntalAlign =Left/>

< itemstyle horizo​​ntalalign =Left>

< asp:TemplateField> ;

< itemtemplate>

< asp:Button ID =btnAddNewRowToolTip =Add New ContractCommandArgument =RowId

CommandName =AddCssClass =GridAddbtnrunat =server/>

< asp:Button ID =btnDeleteToolTip =DeleteCom mandArgument =RowIdCommandName =DeleteCssClass =GridDeletebtnrunat =server/>



< HeaderStyle Font-Bold =true字体-Names =Tahoma字体大小=12px宽度=5%BackColor =#8DC894ForeColor =绿色Horizo​​ntalAlign =Left/>

< itemstyle horizo​​ntalalign =正确>

< alternatingrowstyle backcolor =#C2D69B>

< HeaderStyle BackColor =Green>< / HeaderStyle>

I have a gridview. i'm using AutoCompleteExtender inside gridview. I have add and delete button inside gridview. when i added second row AutoCompleteExtenderis not working.

<asp:GridView ID="grdItems" runat="server" AutoGenerateColumns="False" Font-Names="Arial"
ClientIDMode="Static" CssClass="table table-striped table-bordered table-hover" Width="100%"
Font-Size="11pt" AlternatingRowStyle-BackColor="#C2D69B" HeaderStyle-BackColor="green" AllowPaging="True" ShowFooter="True" OnRowCommand="grdItems_RowCommand"
DataKeyNames="RowId">
<columns> <asp:TemplateField HeaderText="ItemName">
<itemtemplate>
<asp:TextBox ID="txtItem" runat="server" CssClass="form-control" OnTextChanged="txtItem_TextChanged" AutoPostBack="true"
text='<%# Bind("ItemName") %>' autocomplete="off" TabIndex="1">
<asp:HiddenField ID="txtItemId" runat="server" Value='<%# Bind("ItemId") %>' />
<asp:AutoCompleteExtender ID="AutoCompleteExtender1" runat="server" BehaviorID="AutoCompleteEx"
TargetControlID="txtItem" ServicePath="../../WebServices/AutoComplete.asmx" ServiceMethod="GetItems"
MinimumPrefixLength="1" CompletionInterval="200" EnableCaching="true" CompletionSetCount="20"
DelimiterCharacters=";, :" ShowOnlyCurrentWordInCompletionListItem="true" CompletionListCssClass="autocomplete_completionListElement"
CompletionListItemCssClass="autocomplete_listItem" CompletionListHighlightedItemCssClass="autocomplete_highlightedListItem">
<animations>
<onshow>
<sequence>
<%-- Make the completion list transparent and then show it --%>
<opacityaction opacity="0">
<hideaction visible="true">

<%--Cache the original size of the completion list the first time
the animation is played and then set it to zero --%>
<ScriptAction Script="
// Cache the size and setup the initial size
var behavior = $find('AutoCompleteEx');
if (!behavior._height) {
var target = behavior.get_completionList();
behavior._height = target.offsetHeight - 2;
target.style.height = '0px';
}" />
<%-- Expand from 0px to the appropriate size while fading in --%>
<parallel duration=".4">
<fadein>
<length propertykey="height" startvalue="0" endvaluescript="$find('AutoCompleteEx')._height">



<onhide>
<%-- Collapse down to 0px and fade out --%>
<parallel duration=".4">
<fadeout><length propertykey="height" startvaluescript="$find('AutoCompleteEx')._height" endvalue="0">



<HeaderStyle Font-Bold="true" Font-Names="Tahoma" Font-Size="12px" Width="35%" BackColor="#8DC894"
ForeColor="Green" HorizontalAlign="Left" />
<itemstyle horizontalalign="Left">
<asp:TemplateField>
<itemtemplate>
<asp:Button ID="btnAddNewRow" ToolTip="Add New Contract" CommandArgument="RowId"
CommandName="Add" CssClass="GridAddbtn" runat="server" />
<asp:Button ID="btnDelete" ToolTip="Delete" CommandArgument="RowId" CommandName="Delete" CssClass="GridDeletebtn" runat="server" />

<HeaderStyle Font-Bold="true" Font-Names="Tahoma" Font-Size="12px" Width="5%" BackColor="#8DC894" ForeColor="Green" HorizontalAlign="Left" />
<itemstyle horizontalalign="Right">
<alternatingrowstyle backcolor="#C2D69B">
<HeaderStyle BackColor="Green"></HeaderStyle>

解决方案

find('AutoCompleteEx');
if (!behavior._height) {
var target = behavior.get_completionList();
behavior._height = target.offsetHeight - 2;
target.style.height = '0px';
}" />
<%-- Expand from 0px to the appropriate size while fading in --%>
<parallel duration=".4">
<fadein>
<length propertykey="height" startvalue="0" endvaluescript="


find('AutoCompleteEx')._height">



<onhide>
<%-- Collapse down to 0px and fade out --%>
<parallel duration=".4">
<fadeout><length propertykey="height" startvaluescript="


find('AutoCompleteEx')._height" endvalue="0">



<HeaderStyle Font-Bold="true" Font-Names="Tahoma" Font-Size="12px" Width="35%" BackColor="#8DC894"
ForeColor="Green" HorizontalAlign="Left" />
<itemstyle horizontalalign="Left">
<asp:TemplateField>
<itemtemplate>
<asp:Button ID="btnAddNewRow" ToolTip="Add New Contract" CommandArgument="RowId"
CommandName="Add" CssClass="GridAddbtn" runat="server" />
<asp:Button ID="btnDelete" ToolTip="Delete" CommandArgument="RowId" CommandName="Delete" CssClass="GridDeletebtn" runat="server" />

<HeaderStyle Font-Bold="true" Font-Names="Tahoma" Font-Size="12px" Width="5%" BackColor="#8DC894" ForeColor="Green" HorizontalAlign="Left" />
<itemstyle horizontalalign="Right">
<alternatingrowstyle backcolor="#C2D69B">
<HeaderStyle BackColor="Green"></HeaderStyle>


这篇关于gridview isue中的AutoCompleteExtender的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆