我有一个webform,我输入数据并在gridview中显示最少的数据,到目前为止一切都很好,现在我需要在gridview中编辑数据,编辑应该在弹出窗口中完成。我想到了使用相同的表格进行编辑和添加数据。我们可以用相同的形式为编辑添加和jquery对话吗。截至目前我做了以下方式。我面临的问题是当我点击gridview中的编辑按钮时,Jquery dilogue将会更新,如果我关闭它,表单只显示gridview,我重复使用它进行编辑的部分在添加部分中消失了。有没有办法维护表单,如果我关闭jquery对话,我应该使用我开始编辑的数据来获取添加表单和网格视图。到目前为止我所做的是在jquery的关闭事件中我使用location.reload(true);
刷新了页面,但是通过这样做,我将丢失数据我正在编辑的gridview和表格。这就是我所做的
<div id="idTestForm">
<div style="font-weight: bold; font-size: 11pt; color: white; background-color: #6699ff;">
<div>
Leaf Details
</div>
</div>
<asp:UpdatePanel ID="updatePnlForm" runat="server">
<ContentTemplate>
<div class="divTable" style="padding-top: 5px">
<div class="divRow">
<div class="divCell">
<asp:Label ID="lblRegionCode" Text="Region Code:" runat="server"></asp:Label>
</div>
<div class="divCell">
<asp:DropDownList ID="drpRegionCode" Width="150px" AutoPostBack="true" runat="server" OnSelectedIndexChanged="drpRegionCode_SelectedIndexChanged">
</asp:DropDownList>
</div>
<div class="divCell">
<asp:Label ID="lblleafId" Text="Bsc Id:" runat="server"></asp:Label>
</div>
<div class="divCell">
<asp:TextBox ID="txtLeafId" Width="150px" runat="server"></asp:TextBox>
</div>
</div>
<div>
<div>
<asp:Button ID="btnSave" runat="server" Text="Save" OnClick="btnSave_Click" /> <asp:Button ID="btnSearch" runat="server" Text="Search" OnClick="btnSearch_Click" /> <asp:Button ID="btnClear" runat="server" Text="Clear" OnClick="btnClear_Click" />
</div>
</div>
</ContentTemplate>
</asp:UpdatePanel>
<div id="divGrdBsc">
<asp:UpdatePanel ID="updatePnlGrid" runat="server">
<ContentTemplate>
<div style="padding-top: 15px; padding-left: 10px; padding-bottom: 10px">
<asp:Label ID="lblTotalCount" Text="" runat="server"></asp:Label>
</div>
<div class="divRow" style="padding-top: 40px">
<div class="divCell">
<asp:GridView ID="grdLeaf" runat="server" AutoGenerateColumns="False" DataKeyNames="BSC_ID,BSC_NAME,REGION_CODE,TECH_CODE,VENDOR_CODE,
EXCHANGE_CODE,STATUS_CODE,BSC_LOCATION"
CellPadding="4" ForeColor="#333333" GridLines="None" OnRowCommand="grdBsc_RowCommand" OnRowDataBound="grdBsc_RowDataBound">
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
<Columns>
上面只发布了几个输入控件,实际上有很多,保存数据后会显示在gridview中
此后当有人点击Gridvew编辑按钮时,在行命令中我调用了如下所示的javascript
<script type="text/javascript">
function showBscDetails() {
$("#idTestForm").dialog({
open: function () {
$(this).parents(".ui-dialog:first").find(".ui-dialog-titlebar").addClass("ui-state-error");
},
title: 'Leaf Details',
appendTo: "form",
modal: true,
draggable: true,
resizable: true,
show: 'blind',
hide: 'blind',
width: 1100,
height: 600
}).prev(".ui-dialog-titlebar").css("background", "#6A7667");
$("#idTestForm").on('dialogclose', function (event) {
location.reload(true);
});
}
答案 0 :(得分:0)
最后我解决了这个问题。我做的是我创建了一个Usercontrol,其中包含用于添加和编辑的常用控件,并在单个页面中重用了用户控件。单独的更新面板中的所有内容:)