在将更新面板放置到我的转发器详细信息部门后,转发器在每次单击编辑按钮或其他按钮时崩溃。(转发器具有带有切换功能的标题和详细信息划分)我有一个隐藏的文件,它有助于编辑更新...没有折叠详细信息部门。在添加更新面板之前,当我单击转发器详细信息部分的编辑按钮时,文本框将变为启用状态,并将显示取消和保存按钮而不折叠。添加更新面板后,编辑、更新、保存、取消一切工作正常,但每次单击详细信息部分都在折叠,我必须展开以进行更新。添加更新面板后,项目命令中的所有代码都可以正常工作,除了上面提到的单击编辑时的折叠问题。
代码如下
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSource1">
<ItemTemplate>
<div id='h<%# DataBinder.Eval(Container, "ItemIndex") %>' class="heder"
onclick='ToggleDisplay(<%# DataBinder.Eval(Container, "ItemIndex") %>);' style="border-style: none; font-weight: normal;">
<asp:Panel ID="Panel3" runat="server" Height="30px" BorderStyle="None" BackColor="#DCE4FA">
<asp:HiddenField ID="hdnItemIndex" runat ="server" Value='<%# DataBinder.Eval (Container, "ItemIndex") %>' />
<%# DataBinder.Eval(Container.DataItem, "LicenseID")%>
</asp:Panel>
</div>
<div id='d<%# DataBinder.Eval(Container, "ItemIndex") %>' class="details">
<asp:Panel ID="Panel2" runat="server" Height="195px" BackColor="Gray" Font-Bold="False" ForeColor="Maroon">
<br />
<asp:TextBox ID="TextBox2" runat="server" Text='<%# DataBinder.Eval(Container.DataItem,"LicenseName")%>' Enabled="false" BackColor="Gray" BorderStyle="None"></asp:TextBox>
<asp:LinkButton ID="lnkEdit" runat="server" CommandName="edit" CommandArgument='<%# DataBinder.Eval(Container.DataItem, "LicenseID") %>' Font-Bold="True" ForeColor="Black" >Edit</asp:LinkButton>
</asp:Panel>
</div>
</ItemTemplate>
</asp:Repeater>
</ContentTemplate>
</asp:UpdatePanel>
代码背后
Protected Sub Repeater1_ItemCommand(source As Object, e As System.Web.UI.WebControls.RepeaterCommandEventArgs) Handles Repeater1.ItemCommand
If e.CommandName.ToLower() = "edit" Then
Dim hdnItemIndex As HiddenField = DirectCast(DirectCast(e.CommandSource, LinkButton).NamingContainer.FindControl("hdnItemIndex"), HiddenField)
Dim myScript As String = "ToggleDisplay(" + hdnItemIndex.Value & ");"
Page.ClientScript.RegisterStartupScript(Me.[GetType](), "RegisterStartupScript", myScript, True)
End If
For Each rptItem As RepeaterItem In Repeater1.Items
Dim Textbox1 As TextBox = DirectCast(rptItem.FindControl("Textbox1 "), TextBox)
If Textbox1 IsNot Nothing Then
Response.Write(Textbox1.Text)
End If
Next
If e.CommandName = "edit" Then
DirectCast(e.Item.FindControl("TextBox2"), TextBox).Enabled = True
DirectCast(e.Item.FindControl("Textbox2"), TextBox).BorderStyle = BorderStyle.NotSet
DirectCast(e.Item.FindControl("Textbox2"), TextBox).BackColor = Drawing.Color.White
End if
提前致谢