我有一个具有 2 级 web 选项卡的页面。内容选项卡 FIXED 和 VARIABLE 依次具有 Web 选项卡。此 Web 选项卡加载有一个具有网格视图的用户控件。我的问题是 Gridview 中的文本框在从一个子选项卡转到下一个子选项卡时未清除。我尝试了所有可能的方法:1.将网格绑定到 null(数据源和 DatasoruceId)2.网格处置 3.网格列清除没有运气!!!..帮助!!!注意:我正在从 javascript 修改文本框中的数据。
<ig:Webtab id="wi" runat="server" width="938px" displaymode="Scrollable" meta:resourcekey="wtabInvestmentTypeResource1">
<ClientEvents SelectedIndexChanging="webTab_SelectedIndexChanging" />
<AutoPostBackFlags SelectedIndexChanged="On" />
<Tabs>
<ig:ContentTabItem runat="server" Text="Variable Investment Type" meta:resourcekey="ContentTabItemResource1">
<Template>
<div class="clear vspacesmall hspacenarrow">
</div>
<ig:WebTab ID="wv" runat="server" Width="908px" DisplayMode="Scrollable" ClientIDMode="Static"
meta:resourcekey="wtabVariableResource1">
<ClientEvents SelectedIndexChanging="webTab_SelectedIndexChanging" />
<AutoPostBackFlags SelectedIndexChanged="On" />
</ig:WebTab>
</Template>
</ig:ContentTabItem>
<ig:ContentTabItem runat="server" Text="Fixed Investment Type" meta:resourcekey="ContentTabItemResource2">
<Template>
<div class="clear vspacesmall hspacenarrow">
</div>
<ig:WebTab ID="wf" runat="server" Width="908px" DisplayMode="Scrollable" class="tabs"
meta:resourcekey="wtabFixedResource1">
<ClientEvents SelectedIndexChanging="webTab_SelectedIndexChanging" />
<AutoPostBackFlags SelectedIndexChanged="On" />
</ig:WebTab>
Web 选项卡加载具有以下 gridview 的用户控件:
<div class="clear vspacesmall gridtablearea scrollPanel-horizontal Contol-Max-Height">
<asp:UpdatePanel ID="upBuyMultipleGetDiscount" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:GridView ID="gvInvestmentDetails" runat="server" OnRowDataBound="gvInvestmentDetails_RowDataBound"
TabIndex="5" AutoGenerateColumns="False" CssClass="gridtable scrollPanel-horizontal" Width="100%" meta:resourcekey="gvInvestmentDetails_DefaultResource1"
EnableViewState="true" ViewStateMode="Enabled" ShowFooter="true" OnRowCommand="gvInvestmentDetails_Row_Command">
<Columns>
<asp:BoundField DataField="InvestmentTypeId" />
<asp:BoundField DataField="CustomerCombinationId" />
<asp:BoundField DataField="ProductId" />
<asp:TemplateField HeaderText="Account" ItemStyle-Width="100px" meta:resourcekey="Account">
<ItemTemplate>
<asp:Label ID="lblAccountName" runat="server" Text='<%# Eval("CustomerCombinationName") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Products" ItemStyle-Width="200px" meta:resourcekey="Products">
<ItemTemplate>
<asp:Label ID="lblProductName" runat="server" Text='<%# Eval("ProductName") %>'></asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:Label ID="lblTotal" CssClass="fRight boldText" ForeColor="#656565" runat="server" Text='TOTAL :' meta:resourcekey="lblTotal"></asp:Label>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Phase Investment Amount" meta:resourcekey="PhaseInvestmentAmount" >
<ItemTemplate>
<asp:Repeater ID="rptrPhases" runat="server" ClientIDMode="Static" OnDataBinding="rptrPhases_OnDataBinding">
<ItemTemplate>
<div style="float: left; padding: 4px;">
<table id="PhaseDetails">
<tr>
<td>
<tr>
<asp:Label ID="lblPhaseID" runat="server" Text='<%# Eval("PhaseID") %>' Visible="False"></asp:Label>
<asp:Label ID="lblPhaseName" Class="vspacesmall" runat="server" Text='<%# Eval("PhaseName") %>' ></asp:Label><br />
<asp:TextBox ID="txtPhaseAmount" runat="server" Text='<%# Eval("PhaseAmount", "{0:F2}") %>' CssClass="tar"
ClientIDMode="Static" Width="80px" MaxLength="27" onpaste="return false;" ViewStateMode="Enabled"
meta:resourcekey="txtPhaseAmount"></asp:TextBox>
</tr>
<tr>
<asp:Label ID="lblUsageAmount" runat="server" Visible="false" Text='<%# Eval("PhaseUpdateAmount", "{0:F2}") %>'></asp:Label>
</tr>
</td>
</tr>
</table>
</div>
</ItemTemplate>
</asp:Repeater>
</ItemTemplate>
<FooterTemplate>
<asp:Repeater ID="rptTotalAmount" runat="server" ClientIDMode="Static">
<ItemTemplate>
<div style="float: left; padding: 4px;">
<table>
<tr>
<td>
<asp:TextBox ID="txtPhaseTotal" Text='<%# Eval("PhaseAmount", "{0:F2}") %>' Width="80px" CssClass="tar boldText"
ForeColor="#656565" runat="server" ViewStateMode="Enabled" ClientIdMode="Static" autocomplete="off" ></asp:TextBox>
</td>
</tr>
</table>
</div>
</ItemTemplate>
</asp:Repeater>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Roles" ItemStyle-Width="150px" meta:resourcekey="Roles">
<ItemTemplate>
<asp:CheckBoxList ID="chckRoleList" runat="server" DataTextField="RoleName"
DataValueField="RoleId" EnableViewState="true" ViewStateMode="Enabled" onclick="checkBoxLstChanged(this.id,'chkSelectAll');SetIsChanged('1');">
</asp:CheckBoxList>
<asp:RadioButtonList ID="rdbRoleList" runat="server" DataTextField="RoleName"
DataValueField="RoleId" EnableViewState="true" ViewStateMode="Enabled">
</asp:RadioButtonList>
</ItemTemplate>
<FooterTemplate>
<asp:CheckBox ID="chckSelectAll" runat="server" Text="Select All" onclick="setAllCheckBoxes('chckRoleList',this);SetIsChanged('1');" meta:resourcekey="chckSelectAll">
</asp:CheckBox>
<br>
<asp:Button ID="btnRemove" runat="server" CssClass="btnStyle fLeft" Text="Remove" OnClientClick="return ValidateRemoveRoles('gvInvestmentDetails')"
CommandName="RemoveRoles" CommandArgument='<%# Container.DataItemIndex %>'
meta:resourcekey="btnRemove" />
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="InvestmentAmount" meta:resourcekey="InvestmentAmount">
<ItemTemplate>
<asp:TextBox ID="txtInvAmt" Width="80px" runat="server" Text='<%# Eval("InvestmentAmount","{0:F2}") %>'
ClientIdMode="Static" ViewStateMode="Enabled" CssClass="fRight tar boldText" ></asp:TextBox >
</ItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtTotalInvestment" ClientIdMode="Static" Width="80px" ViewStateMode="Enabled" CssClass="fRight tar boldText " ForeColor="#656565" runat="server" />
</FooterTemplate>
</asp:TemplateField>
<asp:BoundField DataField="RecordStatus" />
</Columns>
<%-- <FooterStyle HorizontalAlign="Left" CssClass="boldText" ForeColor="#656565" />--%>
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
</div>
加载 USer 控件的后端代码:
private void LoadInvestmentDetails(int investmentTypeId, WebTab currentWebTab, int tabIndex)
{
Panel panel = GetPanelToBeLoaded(investmentTypeId);
if (currentWebTab.Tabs[tabIndex].Controls.Count == 0)
{
currentWebTab.Tabs[tabIndex].Controls.Add(panel);
budgetDetailsControl.Initialize(investmentTypeId);
budgetDetailsControl.InvestmentDetailsSaved += new ProjectInvestmentDetailsSavedEventHandler(BudgetDetailsControl_BudgetDetailsSaved);
PreviouslyLoadedTab = int.Parse(currentWebTab.Tabs[currentWebTab.SelectedIndex].UserControlUrl);
}
// other code
}
private Panel GetPanelToBeLoaded(int investmentTypeId)
{
System.Web.UI.Control userControl = GetInvestmentDetailsUserControlUrl();
Panel panel = new Panel();
panel.Controls.Add(userControl);
budgetDetailsControl = (IProjectInvestmentDetailsControl)userControl;
budgetDetailsControl.InvestmentTypeID = investmentTypeId;
return panel;
}
private System.Web.UI.Control GetInvestmentDetailsUserControlUrl()
{
return LoadControl(ProjectCommonKeys.URL_PROJECT_BUDGET_DETAILS);
}
Usercontrol实现IprojectInvestmentDetails接口,首先调用UC的initialize函数进行绑定等