下面是我在JavaScript中展开/折叠gridview行的Javascript
<script type="text/javascript">
function divexpandcollapse(divname) {
var div = document.getElementById(divname);
var img = document.getElementById('img' + divname);
if (div.style.display == "none") {
div.style.display = "inline";
img.src = "Img1/minus.gif";
} else {
div.style.display = "none";
img.src = "Img1/plus.gif";
}
}
</script>
这是我的gridview模板字段
<asp:TemplateField>
<ItemTemplate>
<a href="JavaScript:divexpandcollapse('div<%# Eval("ClaimMasterId") %>');">
<img id='imgdiv<%# Eval("ClaimMasterId") %>' width="9px" border="0" src="Img1/plus.gif" alt="" title="Add Action Notes" /></a>
</ItemTemplate>
<ItemStyle Width="10px" VerticalAlign="Middle"></ItemStyle>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<tr>
<td colspan="100%" style="background:#F5F5F5">
<div id='div<%# Eval("ClaimMasterId") %>' style="overflow:auto; display:none; position: relative; left: 15px; overflow: auto;">
<div style="width:900px; -webkit-box-shadow: 0 6px 12px rgba(0,0,0,.175); box-shadow: 0 6px 12px rgba(0,0,0,.175); -moz-box-shadow: 0 6px 12px rgba(0,0,0,.175);">
<table>
<tr>
<td style="vertical-align:top">
<asp:RadioButtonList ID="MoveToRBL" runat="server" RepeatDirection="Horizontal" AutoPostBack="true" OnSelectedIndexChanged="MoveToRBL_SelectedIndexChanged" >
<asp:ListItem Text="Review" Value="Review" Selected="True"></asp:ListItem>
<asp:ListItem Text="Call" Value="Call"></asp:ListItem>
<asp:ListItem Text="Re-Call" Value="ReCall"></asp:ListItem>
<asp:ListItem Text="Audit" Value="Audit"></asp:ListItem>
</asp:RadioButtonList>
</td>
<td style="vertical-align:top">
<asp:ImageButton ID="SaveButton" runat="server" ImageUrl="~/Img1/save32.png" ToolTip="Save" OnClick="SaveButton_Click" />
</td>
</tr>
</table>
</div>
</div>
</td>
</tr>
</ItemTemplate>
<ItemStyle Width="1px" ></ItemStyle>
</asp:TemplateField>
扩张&amp;折叠工作正常但无论何时单击RadioButttonList“MoveToRBL”,扩展的div都会折叠。然后我需要再次单击加号以展开它。它为什么会发生,如何阻止它。我需要在Javascript中更改任何内容,请告诉我。
答案 0 :(得分:0)
通过条件模式实现UpdatePanel,如下所示。
<asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional" >
<ContentTemplate>
<asp:DropDownList ID="AllocateToDDL" runat="server" CssClass="dropdown" Visible="true" Width="135px" AppendDataBoundItems="True" DataSourceID="GetARmembers" DataTextField="EmpName" DataValueField="EmpName" >
<asp:ListItem Text="Select the Caller" Value="NA" Selected="True"></asp:ListItem>
</asp:DropDownList>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="MoveToRBL" EventName="SelectedIndexChanged" />
</Triggers>
</asp:UpdatePanel>