I'm trying to hide the TabPanel4 when the application start, then when user select specific item from the dropdownlist it then display the TabPanel4 out for the user. Below is the code I used, not sure why it not working. Do help me take a look at my code see which part did I do wrongly. Thanks!
Aspx
<asp:TabContainer ID="TabContainer1" runat="server" Height="75%" Width="100%" UseHorizontalStripPlacement="true"
ActiveTabIndex="0" OnDemand="true" AutoPostBack="true" TabStripPlacement="Top" ScrollBars="Auto">
<asp:TabPanel ID="TabPanel1" runat="server" HeaderText="Incident Information" Enabled="true" ScrollBars="Auto" OnDemandMode="Once">
<ContentTemplate>
<table width="100%">
<tr>
<td>
<b>Type of crime:</b>
<asp:DropDownList ID="ddlToC" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlToC_SelectedIndexChanged">
<asp:ListItem>Accident</asp:ListItem>
<asp:ListItem>Theft</asp:ListItem>
<asp:ListItem>Robbery</asp:ListItem>
<asp:ListItem>Housebreaking</asp:ListItem>
<asp:ListItem>Fraud</asp:ListItem>
<asp:ListItem>Loan Shark</asp:ListItem>
</asp:DropDownList>
<br />
</td>
</tr>
</table>
</ContentTemplate>
</asp:TabPanel>
<asp:TabPanel ID="TabPanel4" runat="server" HeaderText="Property" Enabled="true" ScrollBars="Auto" OnDemandMode="Once" Visible="false">
<ContentTemplate>
Is there any property lost in the incident?
<asp:RadioButton ID="rbPropertyYes" runat="server" GroupName="rbGroup3" Text="Yes" AutoPostBack="True" />
<asp:RadioButton ID="rbPropertyNo" runat="server" GroupName="rbGroup3" Text="No" AutoPostBack="True" />
<br />
<br />
<asp:Label ID="Label4" runat="server" Text="Describe what was lost in the incident." Visible="False"></asp:Label>
<br />
<br />
<asp:TextBox ID="txtProperty" runat="server" Height="75px" TextWrapping="Wrap" TextMode="MultiLine" Width="400px" Visible="False"/>
<br />
<br />
<asp:Label ID="Label5" runat="server" Text="You have " Visible="False"></asp:Label><asp:Label ID="lblCount3" runat="server" Text="500" Visible="False"></asp:Label> <asp:Label ID="Label6" runat="server" Text=" characters left." Visible="False"></asp:Label>
</ContentTemplate>
</asp:TabPanel>
</asp:TabContainer>
Code behind
protected void ddlToC_SelectedIndexChanged(object sender, EventArgs e)
{
if (ddlToC.SelectedValue.Equals("Theft"))
{
TabPanel4.Visible = true;
}
else if (ddlToC.SelectedValue.Equals("Robbery"))
{
TabPanel4.Visible = true;
}
else if (ddlToC.SelectedValue.Equals("Housebreaking"))
{
TabPanel4.Visible = true;
}
else if (ddlToC.SelectedValue.Equals("Fraud"))
{
TabPanel4.Visible = true;
}
}
To add on: even I take away the Visible="false" from the aspx page and set it in code behind page under Page_Load it don't work, it still don't appear when I select the item in the dropdownlist. Also tried using TabContainer1.Tabs[3].Visible = false / true; to hide or display it but it also don't seem to work.
ddlToC is not handling SelectedIndexChanged.
Change your markup to this:
<asp:DropDownList ID="ddlToC" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlToC_SelectedIndexChanged">
Related
I'm trying to implement a reinitialization button in my page which is linked to an UpdatePanel (AsyncPostBackTrigger). When i click on the button, it deals with an UpdateProgress.
The problem is that, because the reinitialization button is linked with an update panel, it cannot reinitialize what is outside of the UpdatePanel.
Is there a way to do some changes to the controls outside of the UpdatePanel without adding an UpdatePanel for the whole page ? In this case, i want to reinitialize the DropDownLists, the Textbox and the Repeater contained in the UpdatePanel.
How the page is rendered
ASPX code :
<body style="padding: 50px;">
<form id="form1" runat="server">
<asp:Label runat="server" ID="test"></asp:Label>
<asp:HiddenField runat="server" ID="AllDemandsTypeHfi"></asp:HiddenField>
<asp:ScriptManager runat="server" ID="ScriptManager"></asp:ScriptManager>
<asp:Panel runat="server" CssClass="panel-page-title">Création de demande</asp:Panel>
<asp:Panel runat="server" CssClass="panel-primary">
<asp:Panel runat="server" CssClass="panel-heading">Configuration de la recherche</asp:Panel>
<asp:Panel runat="server" CssClass="panel-body">
<asp:Table runat="server">
<asp:TableRow ID="BankRow">
<asp:TableCell>
<asp:Label runat="server">Banque : </asp:Label>
</asp:TableCell>
<asp:TableCell>
<asp:DropDownList runat="server" ID="BankDdl" AutoPostBack="true" OnSelectedIndexChanged="BankDdl_SelectedIndexChanged"></asp:DropDownList>
</asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell>
<asp:Label runat="server">Famille : </asp:Label>
</asp:TableCell>
<asp:TableCell>
<asp:DropDownList runat="server" ID="FamilyDdl" AutoPostBack="true" OnSelectedIndexChanged="FamilyDdl_SelectedIndexChanged"></asp:DropDownList>
</asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell>
<asp:Label runat="server">Motif : </asp:Label>
</asp:TableCell>
<asp:TableCell>
<asp:DropDownList runat="server" ID="MotiveDdl" AutoPostBack="true" OnSelectedIndexChanged="MotiveDdl_SelectedIndexChanged"></asp:DropDownList>
</asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell>
<asp:Label runat="server">Sous-motif : </asp:Label>
</asp:TableCell>
<asp:TableCell>
<asp:DropDownList runat="server" ID="SubmotiveDdl" AutoPostBack="true" OnSelectedIndexChanged="SubmotiveDdl_SelectedIndexChanged"></asp:DropDownList>
</asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell>
<asp:Label runat="server">Mots-clés : </asp:Label>
</asp:TableCell>
<asp:TableCell>
<asp:TextBox runat="server" ID="KeywordsTbx" data-target="#modalSuggestions" data-toggle="modal"></asp:TextBox>
<div id="keywordsTbxSuggestions"></div>
<asp:HiddenField runat="server" ID="KeywordsSearchHfi"></asp:HiddenField>
</asp:TableCell>
</asp:TableRow>
</asp:Table>
<br />
<asp:Button runat="server" ID="ResearchBtn" Text="Rechercher" OnClick="ResearchBtn_Click" />
<asp:Button runat="server" ID="ReinitializeBtn" Text="Réinitialiser" OnClick="ReinitializeBtn_Click" />
</asp:Panel>
</asp:Panel>
<br />
<asp:UpdatePanel runat="server" ID="ResultsUpnl" ChildrenAsTriggers="true" UpdateMode="Conditional">
<ContentTemplate>
<asp:Panel runat="server" CssClass="panel-primary">
<asp:Panel runat="server" CssClass="panel-heading">Résultat de la recherche </asp:Panel>
<asp:Panel runat="server" CssClass="panel-body">
<asp:Label runat="server" ID="ResultsLb" Text="Veuillez sélectionner les critères de recherche, puis cliquer sur Rechercher."></asp:Label>
<asp:Repeater runat="server" ID="ResultsRpt">
<HeaderTemplate>
<asp:Label runat="server" Text="<b>Type de demande</b>"></asp:Label>
<table>
</HeaderTemplate>
<ItemTemplate>
<asp:Panel runat="server">
<asp:HyperLink runat="server" NavigateUrl='<%# Eval("Link") %>' Text='<%# Eval("Title") %>' Target="_blank"></asp:HyperLink>
</asp:Panel>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
</asp:Panel>
</asp:Panel>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="ResearchBtn" EventName="Click" />
<asp:AsyncPostBackTrigger ControlID="ReinitializeBtn" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
<asp:UpdateProgress ID="UppDemandsResult" runat="server" DisplayAfter="0">
<ProgressTemplate>
<div style="text-align: center;">
<table style="width: 100%;">
<tr>
<td>
<Loader:LoaderComponent ID="UcLoadingProgess" runat="server" />
</td>
</tr>
</table>
</div>
</ProgressTemplate>
</asp:UpdateProgress>
</form>
</body>
Code-behind :
private void HandleReinitialization()
{
this.ResultsLb.Text = DemandCreationConstants.ResearchDefaultText;
this.familyDdlSelectedValue = string.Empty;
this.motiveDdlSelectedValue = string.Empty;
this.submotiveDdlSelectedValue = string.Empty;
this.LoadFamilies(true);
this.LoadMotives(false);
this.LoadSubmotives(false);
this.ResultsRpt.DataSource = null;
this.ResultsRpt.DataBind();
this.KeywordsSearchHfi.Value = string.Empty;
this.KeywordsTbx.Text = string.Empty;
LogServiceInstance.Debug("L'utilisateur " + UserSession.UserLogOn + " a réinitialisé la recherche.");
}
HandleReinitialization is launched by the event ReinitializeBtn_Click.
If understand you correctly, you will need to create UpdatePanel2 and add whatever controls into it, then in the button Click() method of the first UpdatePanel1 invoke the Update() method.
UpdatePanel2.Update();
Update:
Make sure you set the UpdateMode of UpdatePanel2 to "Conditional"
<asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">
<ContentTemplate>
// Your controls
</ContentTemplate>
</asp:UpdatePanel>
Is anyone able to understand why m I getting this error?
Uncaught Sys.WebForms.PageRequestManagerServerErrorException: Sys.WebForms.PageRequestManagerServerErrorException: Object reference not set to an instance of an object.
SOURCE: ScriptResource.axd
So here is the thing...
I have a button when first clicked (after first site access) works, but after that I always get the error. I tried to debug the subject by putting a debug point at the first line in Page_Load event but its not even getting there.
The error is showing before that on that ScriptResources.axd file which is made of javascript so i tried to debug it but i don't really understand what is going on so i couldn't find the problem.
From what i can understand, somehow, when i first click the button, i must not being initialize some controll i should, but i just can't figure it out.
button id = btnFiltra
HTML
<body>
<form id="form1" runat="server">
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
</asp:ToolkitScriptManager>
<script type="text/javascript">
Sys.Application.add_load(onPageLoad);
</script>
<asp:Panel runat="server" ID="pHeader" CssClass="PVHeaderBackground">
<img alt="Planview" src="Images/logo_planview.png" class="PVLogoBackImgleft"/>
<div id="PTLogo" class="PTLogosRight">
<img src="Images/logo_meo_preto.png" alt="Meo" style="vertical-align:middle; margin-top:auto; margin-bottom:auto"/>
<img src="Images/Ptlogo.jpg" alt="PT" style="height:50px; width:auto; margin-left:10px; vertical-align:middle;margin-top:auto; margin-bottom:auto"/>
</div>
</asp:Panel>
<asp:UpdatePanel ID="upBody" runat="server" UpdateMode="Conditional" >
<ContentTemplate>
<asp:Panel runat="server" ID="pOpcoesGlobais" >
<asp:Button ID="btnExtrair" runat="server" OnClientClick="umProjetoApenas()" OnClick="btnExtrair_OnClick" Text="Extrair Dados"/>
<asp:Button ID="btnAtualizar" runat="server" OnClientClick="umProjetoApenas()" OnClick="btnAtualizar_OnClick" Text="Atualizar Dados"/>
</asp:Panel>
<asp:Panel runat="server" ID="pTarefaOkFaturar" Visible="true" style="display:none;" Width="100%" Height="100%" >
<div style="width:100%; height:10%">
<b>Ao confirmar que a tarefa pode ser faturada, todas as parcelas sem documento passarão a ser faturadas de forma automática.</b>
</div>
<div style="width:100%;">
<asp:GridView runat="server" ID="gvCheckParcelas" CssClass="PVPortlet"></asp:GridView>
</div>
<div style="width:100%;position: absolute;bottom: 10px;">
<asp:Button ID="btnOkFaturarCancelar" runat="server" Text="Cancelar" OnClick="btnOkFaturarCancelar_OnClick" style="float:left;margin-left: 10px;"/>
<asp:Button ID="btnOkFaturarOk" runat="server" Text="Concordo" OnClick="btnOkFaturarOk_OnClick" style="float:right;margin-right: 10px;" />
</div>
</asp:Panel>
<asp:Panel runat="server" ID="pBody">
<asp:UpdatePanel ID="upFiltros" runat="server">
<ContentTemplate>
<asp:Label ID="lCliente" runat="server" Text="Cliente"/>
<asp:TextBox ID="txbCliente" runat="server"/>
<asp:PopupControlExtender ID="txbCliente_PopupControlExtender" runat="server" Enabled="True" ExtenderControlID="" TargetControlID="txbCliente"
PopupControlID="pPopUpCliente" Position="Bottom" >
</asp:PopupControlExtender>
<asp:Panel ID="pPopUpCliente" runat="server" Height="116px" BorderStyle="Solid" BorderWidth="2px" Direction="LeftToRight" ScrollBars="Auto" BackColor="#CCCCCC" Style="display: none" >
<asp:CheckBoxList ID="cblCliente" runat="server" DataTextField="DESCRICAO" onChange="uncheckOnTodos(this)" DataValueField="ID" AutoPostBack="False" AppendDataBoundItems="True">
<asp:ListItem Text="Todos" Value="all" Selected="False"></asp:ListItem>
</asp:CheckBoxList>
</asp:Panel>
<asp:Label ID="lPedido" runat="server" Text="Pedido"/>
<asp:TextBox ID="txbPedido" runat="server"/>
<asp:PopupControlExtender ID="txbPedido_PopupControlExtender" runat="server"
Enabled="True" ExtenderControlID="" TargetControlID="txbPedido"
PopupControlID="pPopUpPedido" Position="Bottom" >
</asp:PopupControlExtender>
<asp:Panel ID="pPopUpPedido" runat="server" Height="116px"
BorderStyle="Solid" BorderWidth="2px" Direction="LeftToRight"
ScrollBars="Auto" BackColor="#CCCCCC" Style="display: none" >
<asp:CheckBoxList ID="cblPedido" runat="server"
DataTextField="DESCRICAO" onChange="uncheckOnTodos(this)"
DataValueField="ID" AutoPostBack="False" AppendDataBoundItems="True">
<asp:ListItem Text="Todos" Value="all" Selected="False"></asp:ListItem>
</asp:CheckBoxList>
</asp:Panel>
<asp:Label ID="lProjeto" runat="server" Text="Projeto"/>
<asp:TextBox ID="txbProjeto" runat="server"/>
<asp:PopupControlExtender ID="txbProjeto_PopupControlExtender" runat="server"
Enabled="True" ExtenderControlID="" TargetControlID="txbProjeto"
PopupControlID="pPopUpProjeto" Position="Bottom" >
</asp:PopupControlExtender>
<asp:Panel ID="pPopUpProjeto" runat="server" Height="116px"
BorderStyle="Solid" BorderWidth="2px" Direction="LeftToRight" ScrollBars="Auto" BackColor="#CCCCCC" Style="display: none" >
<asp:CheckBoxList ID="cblProjeto" runat="server"
DataTextField="DESCRICAO" onChange="uncheckOnTodos(this)"
DataValueField="ID" AutoPostBack="False" AppendDataBoundItems="True">
<asp:ListItem Text="Todos" Value="all" Selected="False"></asp:ListItem>
</asp:CheckBoxList>
</asp:Panel>
<asp:Button runat="server" ID="btnFiltra" Text="Pesquisar"
onclick="btnFiltra_Click"/>
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdateProgress ID="uprgTarefas" runat="server" AssociatedUpdatePanelID="upTarefas" DisplayAfter="2000" >
<ProgressTemplate>Loading...</ProgressTemplate>
</asp:UpdateProgress>
<asp:UpdatePanel ID="upTarefas" runat="server">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnFiltra" EventName="Click" />
<asp:AsyncPostBackTrigger ControlID="btnAtualizar" EventName="Click" />
<asp:AsyncPostBackTrigger ControlID="btnExtrair" EventName="Click" />
</Triggers>
<ContentTemplate>
<div id="dTabelaTarefaHeader" class="PVPortletHeader">
<div id="dTabelaTarefasOpcoes" class="PVPortletHeaderOpcoes"></div>
<b>Tarefas Faturação</b>
</div>
<asp:Panel runat="server" ID="pgvTarefasEmpty" Visible="false">
<table class="PVPortlet">
<tbody>
<tr>
<th></th>
<th>ID</th>
<th>Projeto</th>
<th>Tarefa</th>
<th>Cliente</th>
<th>Pedido</th>
<th>Inicio</th>
<th>Fim</th>
<th>Faturar?</th>
<th>Planeado</th>
<th>Remanescente</th>
<th>Faturado</th>
<th>Entidade</th>
</tr>
<tr>
<td colspan="13">Sem dados...</td>
</tr>
</tbody>
</table>
</asp:Panel>
<asp:GridView ID="gvTarefas" runat="server" AutoGenerateSelectButton="true"
AutoGenerateColumns="false" CssClass="PVPortlet" SelectedRowStyle-CssClass="PVPortletSelectedRow"
onselectedindexchanged="gvTarefas_SelectedIndexChanged" DataKeyNames="ID"
OnRowCreated="gvTarefas_OnRowCreated">
<columns>
<asp:BoundField DataField="ID" HtmlEncode="false" HeaderText="ID" />
<asp:BoundField DataField="Projeto" HtmlEncode="false" HeaderText="Projeto" />
<asp:BoundField DataField="Tarefa" HtmlEncode="false" HeaderText="Tarefa" />
<asp:BoundField DataField="Cliente" HtmlEncode="false" HeaderText="Cliente" />
<asp:BoundField DataField="Pedido" HtmlEncode="false" HeaderText="Pedido" />
<asp:BoundField DataField="DataInicio" DataFormatString="{0:dd-MM-yyyy}" HeaderText="Inicio" />
<asp:BoundField DataField="DataFim" DataFormatString="{0:dd-MM-yyyy}" HeaderText="Fim" />
<asp:TemplateField HeaderText="Faturar?">
<ItemTemplate>
<asp:CheckBox runat="server" ID="cbFaturar" Checked='<%# Eval("ProntoAFaturar") %>' AutoPostBack="true" OnCheckedChanged="cb_OnCheckedChanged"/>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="Planeado" HeaderText="Planeado" />
<asp:BoundField DataField="Remanescente" HeaderText="Remanescente" />
<asp:BoundField DataField="Faturado" HeaderText="Faturado" />
<utl:CompositeBoundField HeaderText="Entidade" DataField="EntidadeResponsavel.Descricao" />
</columns>
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
<br />
<br />
<asp:UpdateProgress ID="uprgParcelas" runat="server"
AssociatedUpdatePanelID="upParcelas" DisplayAfter="2000">
<ProgressTemplate>Loading...</ProgressTemplate>
</asp:UpdateProgress>
<asp:UpdatePanel ID="upParcelas" runat="server" UpdateMode="Conditional">
<Triggers>
<asp:asyncpostbacktrigger controlid="gvTarefas"
EventName="SelectedIndexChanged" />
<asp:asyncpostbacktrigger controlid="gvParcelas" EventName="RowEditing" />
</Triggers>
<ContentTemplate>
<div ID="dTabelaParcelasHeader" class="PVPortletHeader">
<b>Parcelas Faturação</b>
</div>
<asp:Panel ID="pgvParcelasEmpty" runat="server" Visible="false">
<table class="PVPortlet">
<tbody>
<tr>
<th></th>
<th>ID</th>
<th>Auto</th>
<th>DataEnvio</th>
<th>Descrição</th>
<th>Valor</th>
</tr>
<tr>
<td colspan="6">Sem dados...</td>
</tr>
</tbody>
</table>
</asp:Panel>
<asp:GridView ID="gvParcelas" runat="server" AutoGenerateColumns="false" AutoGenerateDeleteButton="true" AutoGenerateEditButton="true"AutoGenerateSelectButton="true" CssClass="PVPortlet" DataKeyNames="ID" OnRowCancelingEdit="gvParcelas_OnRowCancelingEdit"
OnRowCommand="gvParcelas_OnRowCommand" OnRowCreated="gvParcelas_OnRowCreated" OnRowDeleting="gvParcelas_OnRowDeleting" OnRowEditing="gvParcelas_RowEditing" OnRowUpdating="gvParcelas_OnRowUpdating" Visible="false" SelectedRowStyle-CssClass="PVPortletSelectedRow"
OnSelectedIndexChanged="obterDocumento_OnSeacrh" ShowFooter="True">
<Columns>
<asp:TemplateField HeaderText="ID">
<EditItemTemplate>
<asp:Label ID="lIDParcela" runat="server" Text='<%# Eval("ID") %>' />
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="lIDParcela" runat="server" Text='<%# Eval("ID") %>' />
</ItemTemplate>
<FooterTemplate>
<asp:Button ID="btnParcelaNovo" runat="server" CommandName="Insert" Text="Novo" />
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Auto">
<EditItemTemplate>
<asp:CheckBox ID="cbAuto" runat="server" Checked='<%# Eval("Auto") %>' />
</EditItemTemplate>
<ItemTemplate>
<asp:CheckBox ID="cbAuto" runat="server" Checked='<%# Eval("Auto") %>' Enabled="false"/>
</ItemTemplate>
<FooterTemplate>
<asp:CheckBox ID="cbAuto" runat="server" Checked="true" />
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="DataEnvio">
<EditItemTemplate>
<asp:TextBox ID="txbDataEnvio" runat="server" Text='<%# Eval("DataEnvio","{0:dd-MM-yyyy}") %>' />
<asp:CalendarExtender ID="txbDataEnvio_CalendarExtender" runat="server"
DefaultView="Months" Enabled="True" Format="MM-yyyy" PopupPosition="BottomLeft"
TargetControlID="txbDataEnvio">
</asp:CalendarExtender>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="lDataEnvio" runat="server"
Text='<%# Eval("DataEnvio","{0:dd-MM-yyyy}") %>' />
</ItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txbDataEnvio" runat="server" Text="" />
<asp:CalendarExtender ID="txbDataEnvio_CalendarExtender" runat="server"
DefaultView="Months" Enabled="True" Format="MM-yyyy" PopupPosition="BottomLeft"
TargetControlID="txbDataEnvio">
</asp:CalendarExtender>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Descrição">
<EditItemTemplate>
<asp:TextBox ID="txbDescricao" runat="server" Text='<%# Eval("Descricao") %>' />
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="lDescricao" runat="server" Text='<%# Eval("Descricao") %>' />
</ItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txbDescricao" runat="server" Text="" />
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Valor">
<EditItemTemplate>
<asp:TextBox ID="txbValor" runat="server" Text='<%# Eval("Valor") %>' />
<asp:FilteredTextBoxExtender ID="txbValor_FilteredTextBoxExtender" runat="server" FilterType="Custom" TargetControlID="txbValor" ValidChars="0123456789,">
</asp:FilteredTextBoxExtender>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="lValor" runat="server" Text='<%# Eval("Valor") %>' />
</ItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txbValor" runat="server" Text="" />
<asp:FilteredTextBoxExtender ID="txbValor_FilteredTextBoxExtender"
runat="server" FilterType="Numbers" TargetControlID="txbValor">
</asp:FilteredTextBoxExtender>
</FooterTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdateProgress ID="uprgDocumentos" runat="server"
AssociatedUpdatePanelID="upDocumentos" DisplayAfter="2000">
<ProgressTemplate>Loading...</ProgressTemplate>
</asp:UpdateProgress>
<asp:UpdatePanel ID="upDocumentos" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<div ID="dTabelaDocumentosHeader" class="PVPortletHeader">
<div ID="dTabelaDocumentosOpcoes" class="PVPortletHeaderOpcoes">
<asp:Label ID="lDocInicio" runat="server" Text="Inicio" style="float:left;"></asp:Label>
<asp:TextBox ID="txbInicio" runat="server" style="float:left;"></asp:TextBox>
<asp:CalendarExtender ID="txbInicio_CalendarExtender" runat="server" Enabled="True" Format="MM-yyyy" TargetControlID="txbInicio">
</asp:CalendarExtender>
<asp:Label ID="lDocFim" runat="server" Text="Fim" style="float:left;"></asp:Label>
<asp:TextBox ID="txbFim" runat="server" style="float:left;"></asp:TextBox>
<asp:CalendarExtender ID="txbFim_CalendarExtender" runat="server" Enabled="True" Format="MM-yyyy" TargetControlID="txbFim">
</asp:CalendarExtender>
<asp:Button ID="btnDocFiltro" runat="server" Text="Pesquisar" style="float:left;" OnClick="obterDocumento_OnSeacrh"/>
</div>
<b>Documentos Faturação</b>
<asp:Button ID="btnNovoDocumento" runat="server" OnClientClick="abrirDocumento(0);" Text="Novo" style="float:right;"/>
</div>
<asp:Panel ID="pgvDocumentosEmpty" runat="server" Visible="false">
<table class="PVPortlet">
<tbody>
<tr>
<th></th>
<th>ID</th>
<th>Fatura</th>
<th>Enviado</th>
<th>Estado</th>
<th>Tipo</th>
<th>Descrição</th>
<th>Valor</th>
</tr>
<tr>
<td colspan="8">Sem dados...</td>
</tr>
</tbody>
</table>
</asp:Panel>
<asp:GridView ID="gvDocumentos" runat="server" AutoGenerateColumns="false" AutoGenerateDeleteButton="false" AutoGenerateEditButton="false" AutoGenerateSelectButton="false" CssClass="PVPortlet">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton Text="Abrir" runat="server" ID="lbtnAbrirDoc" OnClientClick='<%#"abrirDocumento(" + Eval("ID") + ");"%>' />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="ID" HeaderText="ID" HtmlEncode="false" />
<asp:BoundField DataField="NFATURA" HeaderText="Fatura" HtmlEncode="false" />
<asp:BoundField DataField="EnviadoA" DataFormatString="{0:dd-MM-yyyy}" HeaderText="Enviado" HtmlEncode="false" />
<utl:CompositeBoundField DataField="Estado.Descricao" HeaderText="Estado" HtmlEncode="false" />
<utl:CompositeBoundField DataField="Tipo.Descricao" HeaderText="Tipo" HtmlEncode="false" />
<asp:TemplateField HeaderText="Descrição">
<ItemTemplate>
<asp:Label ID="lCabecalho" runat="server" Text='<%#Eval("Cabecalho").ToString().Cut(30,true)+"-"+Eval("Periodo")%>' />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="Valor" HeaderText="Valor" HtmlEncode="false" />
</Columns>
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
</form>
</body>
</html>
Server SIde
protected void Page_Load(object sender, EventArgs e)
{
userName = HttpContext.Current.User.Identity.Name.ToString().ToUpper();
sessionID = Session.SessionID;
if (!IsPostBack)
{
Session["USER_" + sessionID] = userName;
Session["TAREFAS_INV_" + sessionID] = null;
Session["PARCELAS_"+sessionID] = null;
Session["DOCUMENTOS_"+sessionID] = null;
carregaDadosFiltros();
string idPrj = null;
obtemParametrosEntrada(ref idPrj);
pgvDocumentosEmpty.Visible = true;
pgvParcelasEmpty.Visible = true;
pgvTarefasEmpty.Visible = true;
gvDocumentos.Visible = false;
gvParcelas.Visible = false;
gvTarefas.Visible = false;
if (!string.IsNullOrEmpty(idPrj))
{
bool filtra = true;
if (cblProjeto.Items.FindByValue(idPrj) != null)
{
cblProjeto.SelectedValue = idPrj;
}
else
{
string nome = InvDataAccess.obterNomeProjeto(idPrj);
if(!string.IsNullOrEmpty(nome))
{
ListItem prj = new ListItem(nome, idPrj, true);
cblProjeto.Items.Add(prj);
cblProjeto.SelectedValue = prj.Value;
}
else
filtra = false;
}
cblCliente.SelectedValue = "all";
cblPedido.SelectedValue = "all";
if(filtra) btnFiltra_Click(null, null);
}
}
else
{
userName = Session["USER_" + sessionID] as string;
DateTime inicio = DateTime.MinValue, fim = DateTime.MaxValue;
if (!DateTime.TryParseExact(txbInicio.Text, txbInicio_CalendarExtender.Format, null, System.Globalization.DateTimeStyles.None, out inicio))
txbInicio_CalendarExtender.SelectedDate = DateTime.MinValue;
if (!DateTime.TryParseExact(txbFim.Text, txbFim_CalendarExtender.Format, null, System.Globalization.DateTimeStyles.None, out fim))
txbFim_CalendarExtender.SelectedDate = DateTime.MaxValue;
if (Session["TAREFAS_INV_"+sessionID] != null)
tarefas = (Dictionary<int, InvTarefas>)Session["TAREFAS_INV_"+sessionID];
if (Session["PARCELAS_"+sessionID] != null)
{
parcelas = (Dictionary<int, InvParcelaTarefa>)Session["PARCELAS_"+sessionID];
gvParcelas.DataSource = parcelas.Values.ToList();
}
if (Session["DOCUMENTOS_"+sessionID] != null)
{
documentos = (Dictionary<int, InvDocumento>)Session["DOCUMENTOS_"+sessionID];
gvDocumentos.DataSource = documentos.Values.ToList();
}
}
}
protected void btnFiltra_Click(object sender, EventArgs e)
{
tarefas.Clear();
List<string> idCliente, idPedido, idProjeto;
DateTime inicio, fim;
idCliente = cblCliente.Items.Cast<ListItem>().Where(i => i.Selected).Select(i => i.Value).ToList();
idPedido = cblPedido.Items.Cast<ListItem>().Where(i => i.Selected).Select(i => i.Value).ToList();
idProjeto = cblProjeto.Items.Cast<ListItem>().Where(i => i.Selected).Select(i => i.Value).ToList();
inicio = DateTime.MinValue;
fim = DateTime.MaxValue;
List<InvTarefas> tars = InvTarefas.getInvTarefas(new List<string>{"all"}, idCliente, idPedido, idProjeto, inicio, fim);
if (tars != null && tars.Count > 0)
{
foreach (InvTarefas tar in tars)
{
tarefas.Add(tar.ID, tar);
}
this.Session["TAREFAS_INV_"+sessionID] = tarefas;
gvTarefas.DataSource = tarefas.Values.ToList();
gvTarefas.DataBind();
pgvTarefasEmpty.Visible = false;
gvTarefas.Visible = true;
}
else
{
this.Session["TAREFAS_INV_"+sessionID] = null;
pgvTarefasEmpty.Visible = true;
gvTarefas.Visible = false;
}
}
After some help from a colleague, we found that the gvTarefas_OnRowCreated event was firing before the Page_load and that the code inside was trowing null exception.
I was also advised to change my event to OnRowDataBound.
Also, for those of you who didn't knew you can set (when in trouble, otherwise is to much load) VS to stop on the line that throwed the exception by going Debug->Exceptions->Throw in Common Language Runtime Exceptions. If i knew this I probably had solved it right away.
Now, about the strange OnRowCreated before Page_Load, i still can't understand, but something tells me it's because of my UpdatePanel upBody that catches most of the page and its update mode is in Always (is the default value).
Last, i'm putting my OnRowCreated code
protected void gvTarefas_OnRowCreated(Object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
InvTarefas tar = e.Row.DataItem as InvTarefas;
if (tar.EntidadeResponsavel != InvEntidadeResponsavel.PV_PROPRIO)
{
e.Row.Enabled = false;
e.Row.CssClass = "PVPortlet_DisabledRoW";
}
}
}
I want to enable a DropDownList which is in a ListView (ID = "SehensList") and put in an UpdatePanel. My first bet was the following, but it didn't work;
DropDownList DropdownDistrict = (DropDownList)SehenList.InsertItem.FindControl("DistrictDropDownListInsert");
DropdownDistrict.Enabled = true;
Here is the aspx side;
<InsertItemTemplate>
<tr style="">
<td>
<asp:Button ID="InsertButton" runat="server" CommandName="Insert" Text="Insert" />
<asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="Clear" />
</td>
<td>
<asp:TextBox ID="CityFKTextBox_Insert" runat="server" Visible="false" Text='<%# Bind("CityFK") %>' />
<asp:DropDownList ID="CityFKDropDownListInsert" runat="server" DataSourceID="CityFKEntityDataSource_Insert" AutoPostBack="true"
OnSelectedIndexChanged="CityFKDropDownListInsert_SelectedIndexChanged" DataTextField="CityName" DataValueField="CityID"
AppendDataBoundItems="true">
<asp:ListItem Text="-Stadt Wählen-" Value="0" ></asp:ListItem>
</asp:DropDownList>
<asp:EntityDataSource ID="CityFKEntityDataSource_Insert" runat="server"
ConnectionString="name=MedicalEntities" DefaultContainerName="MedicalEntities"
EntitySetName="Cities">
</asp:EntityDataSource>
<asp:ScriptManager ID="SMCityFKInsert" runat="server"></asp:ScriptManager>
<asp:UpdatePanel ID="UPCityFKInsert" runat="server">
<ContentTemplate>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="CityFKDropDownListInsert" EventName="SelectedIndexChanged" />
</Triggers>
</asp:UpdatePanel>
</td>
<td>
<asp:TextBox ID="DistrictTextBox_Insert" runat="server" Visible="false" Text='<%# Bind("District") %>' />
<asp:DropDownList ID="DistrictDropDownListInsert" runat="server" Enabled="false" AutoPostBack="true"
OnSelectedIndexChanged="DistrictDropDownListInsert_SelectedIndexChanged" DataTextField="DistrictName" DataValueField="DistrictID"
AppendDataBoundItems="true">
<asp:ListItem Text="-Stadt Wählen-" Value="0" ></asp:ListItem>
</asp:DropDownList>
<asp:UpdatePanel ID="UPDistrictInsert" runat="server">
<ContentTemplate>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="DistrictDropDownListInsert" EventName="SelectedIndexChanged" />
</Triggers>
</asp:UpdatePanel>
</td>
</tr>
</InsertItemTemplate>
As you notice DropDownLists are outside of the UpdatePanel and are called through "Triggers". If I put the DropDownLists into the UpdatePanel ContentTemplate (I guess, this is a totally wrong approach), second DropDownList "DistrictDropDownListInsert" is enabled but at that case it is not updated more than once. I mean by "not updated more than once" if you change the first DropDownList "CityFKDropDownListInsert" it is set to its previous value (not the default value but the first selected value). I know it's a bit confusing. If you have any unclear part please let me know.
It should be like this:
protected void SehenList_ItemInserting(object sender, ListViewInsertEventArgs e)
{
var pnl = SehenList.InsertItem.FindControl("UPCityFKInsert") as UpdatePanel;
if (pnl != null)
{
var ddlDistrictInsert = pnl.FindControl("DistrictDropDownListInsert") as DropDownList;
if (ddlDistrictInsert != null) ddlDistrictInsert.Enabled = true;
}
}
I've searched, but no luck...
I have a textbox inside an accordion control, that's inside a datalist... I want to allow the accordion form to submit some values, but I can't get those values out of the textbox, and findcontrol isn't working.
<asp:DataList ID="AddProjectDataList" runat="server">
<ItemTemplate>
<asp:HiddenField ID="clientid" runat="server" Value='<%# Eval("mmmclientlistid") %>'></asp:HiddenField>
<asp:Table ID="ProjectTableClass" runat="server" style="width:600px;height:600px"><asp:TableRow><asp:TableCell VerticalAlign="Top">
<b>New <asp:Label ID="ProjectTypeLabel" Text='<%# Eval("ProjectTypeName") %>' runat="server"></asp:Label> Project</b>
<table class="AddProject" cellpadding="5">
<tr>
<td valign="top">
<b>Campaign</b> information:
</td>
<td>
<asp:DropDownList ID="DDCampaignList" runat="server" AutoPostBack="true" OnSelectedIndexChanged="OnChange_selectCampaign" AppendDataBoundItems="True" >
<asp:ListItem Text="SELECT A CAMPAIGN:" Value="-1"></asp:ListItem>
</asp:DropDownList>
<br />
<ajaxToolkit:Accordion
ID="CampaignAccordion"
runat="Server"
SelectedIndex="1"
HeaderCssClass="accordionHeader"
HeaderSelectedCssClass="accordionHeaderSelected"
ContentCssClass="accordionContent"
AutoSize="None"
FadeTransitions="true"
TransitionDuration="250"
FramesPerSecond="40"
RequireOpenedPane="false"
SuppressHeaderPostbacks="true">
<Panes>
<ajaxToolkit:AccordionPane ID="AccordionPane1" runat="server"
HeaderCssClass="accordionHeader"
HeaderSelectedCssClass="accordionHeaderSelected"
ContentCssClass="accordionContent">
<Header>
<asp:LinkButton ID="AddCampaignLink" runat="server">Or Click to Add New Campaign</asp:LinkButton> </Header>
<Content>
<asp:TextBox ID="campaignNameTextBox" Style="width: 400px" runat="server"></asp:TextBox><br />
Description (optional):<br />
<asp:TextBox ID="campaignDescriptionTextBox" runat="server" TextMode="MultiLine"
Columns="30" Rows="3"></asp:TextBox>
<br />
<asp:Button ID="AddCampaignButton" runat="server" Text="Add New Campaign" OnClick="AddCampaign_Click" />
</Content>
</ajaxToolkit:AccordionPane>
</Panes>
<HeaderTemplate>...</HeaderTemplate>
<ContentTemplate>...</ContentTemplate>
And then in the codebehind
protected void AddCampaign_Click(object sender, EventArgs e)
{
//click to add campaign
//campaignname
//clientid
HiddenField EID = (HiddenField)FindControl("HiddenFieldEID");
TextBox campaignNameTextBox = (TextBox)AddProjectDataList.Items[0].FindControl("campaignNameTextBox");
TextBox campaignDescriptionTextBox = (TextBox)AddProjectDataList.Items[0].FindControl("campaignDescriptionTextBox");
tbl_campaign newcampaign = new tbl_campaign();
newcampaign.clientID = Convert.ToInt32(DDClientList.SelectedValue);
newcampaign.employeeID = Convert.ToInt32(HiddenFieldEID.Value);
newcampaign.campaignName = campaignNameTextBox.Text;
newcampaign.campaignDescription = campaignDescriptionTextBox.Text;
db.AddTotbl_campaign(newcampaign);
db.SaveChanges();
}
If I get rid of the accordion pane, it works fine. The control is located no problem. But with the accordion, no such luck. (The "hiddenFieldEID" field is located just fine because it's outside of the accordion.)
Do I need a separate onItemDataBound event in the DataList control? If so, what goes in there, and how do I relate it to the buttonclick event?
Thanks!
Well, I might have just figured it out.
I did this:
Control CampaignAccordion = (Control)AddProjectDataList.Items[0].FindControl("CampaignAccordion");
TextBox campaignNameTextBox = (TextBox)CampaignAccordion.FindControl("campaignNameTextBox");
TextBox campaignDescriptionTextBox = (TextBox)CampaignAccordion.FindControl("campaignDescriptionTextBox");
And it worked. No separate databinding event. Is this the normal way to do it?
I have a Page which has a 2 level web tab . The Content tabs FIXED and VARIABLE in turn has a web tab. This web tab is loaded with a User control which has a gridview.
My problem is the textboxes in the Gridview are not cleared on going from one sub tab to next sub tab . I tried all possible methods :
1.Bind grid to null ( datasource and DatasoruceId )
2. grid dispose
3. grid columns clear
No luck !!!.. HELP!!!
Note : I am modifying the data in the textboxes from 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>
The web tab loads a user control which has the following 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>
The back end code for loading the USer control :
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);
}
The Usercontrol implments the IprojectInvestmentDetails interface and the initalize function of the UC is called first for the binding etc
I figured out the problem. Each user control bound to the sub tab shud be given a unique Id..or else even if we bind new data the data from the earlier instance will persist.
.
private Panel GetPanelToBeLoaded(int investmentTypeId)
{
System.Web.UI.Control userControl = GetInvestmentDetailsUserControlUrl();
**userControl.ID = investmentTypeId.ToString();**
Panel panel = new Panel();
panel.Controls.Add(userControl);
projectInvestmentDetailsControl = (IProjectInvestmentDetailsControl)userControl;
projectInvestmentDetailsControl.InvestmentTypeID = investmentTypeId;
projectInvestmentDetailsControl.UserContext = userContext;
projectInvestmentDetailsControl.PlanningWizardDataManager = PlanningWizardDataManager;
projectInvestmentDetailsControl.PlanningServiceWrapper = PlanningServiceWrapper;
return panel;
}`
Thanks fr the help...