I have a gridview that can have 1 or 2 controls displayed in 1 column when in edit mode depending on the selection of a dropdown in another column. One control is a textbox the other a label. I have the textbox first and the label beside the textbox after it. My problem is when the textbox and label are showing, the label's text extends into the next column. I would like the column width to be as wide as the controls displayed.
How can I do this?
This is my markup for the grid:
<div id="DeviceGridWrapper">
<asp:TextBox ID="RecipientID" runat="server" Visible="false"> </asp:TextBox>
<asp:GridView ID="DeviceInfoGridView" runat="server"
AutoGenerateColumns="False" Caption="Device Information"
CaptionAlign="Top" CssClass="grid" RowStyle-Wrap="true"
HorizontalAlign="Left" ShowFooter="True" PageSize="5"
ShowHeaderWhenEmpty="False"
OnRowCancelingEdit="DeviceInfoGridView_RowCancelingEdit"
OnRowDataBound="DeviceInfoGridView_RowDataBound"
OnRowDeleting="DeviceInfoGridView_RowDeleting"
OnRowEditing="DeviceInfoGridView_RowEditing"
OnRowUpdating="DeviceInfoGridView_RowUpdating" AllowPaging="True"
ondatabound="DeviceInfoGridView_DataBound"
onrowcommand="DeviceInfoGridView_RowCommand">
<Columns>
<asp:TemplateField HeaderText="Device ID">
<ItemTemplate>
<asp:Label ID="digvLblDeviceID" runat="server" Text='<%# Bind("DeviceID") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Device" ItemStyle-Wrap="false">
<ItemTemplate>
<asp:Label ID="digvLblDeviceName" runat="server" Text='<%# Bind("DeviceName") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:Label ID="digvEditDeviceName" runat="server" Visible="false" Text='<%# Bind("DeviceName") %>'></asp:Label>
<asp:DropDownList ID="digvDDListDeviceName" runat="server" ClientIDMode="Static"
data-placeholder="Choose device…" class="chosen-single"></asp:DropDownList>
<asp:RequiredFieldValidator ID="ReqValueDDLDeviceNameEdit" runat="server"
ControlToValidate="digvDDListDeviceName" ValidationGroup="EditDeviceValidation"
ErrorMessage="Selection required." CssClass="message-error-dropdown">
</asp:RequiredFieldValidator>
</EditItemTemplate>
<FooterTemplate>
<asp:DropDownList ID="digvDDListDeviceNameInsert" runat="server" ClientIDMode="Static"
data-placeholder="Choose device…" class="chosen-single">
</asp:DropDownList>
<asp:RequiredFieldValidator ID="ReqValueDDLDeviceNameInsert" runat="server" InitialValue="0"
ControlToValidate="digvDDListDeviceNameInsert" ValidationGroup="InsertDeviceValidation"
ErrorMessage="Selection required." CssClass="message-error-dropdown">
</asp:RequiredFieldValidator>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Service Provider">
<ItemTemplate>
<asp:Label ID="digvLblServiceName" runat="server" Text='<%# Bind("ServiceName") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:Label ID="digvEditServiceName" runat="server" Visible="false" Text='<%# Bind("ServiceName") %>'></asp:Label>
<asp:DropDownList ID="digvDDListServiceName" runat="server" ClientIDMode="Static"
OnSelectedIndexChanged="DeviceInfoGridView_SelectedIndexChanged_EditServiceName" AutoPostBack="true" EnableViewState="true"
data-placeholder="Choose service…" class="chosen-single"></asp:DropDownList>
<asp:RequiredFieldValidator ID="ReqValueDDLServiceNameEdit" runat="server"
ControlToValidate="digvDDListServiceName" ValidationGroup="EditDeviceValidation"
ErrorMessage="Selection required." CssClass="message-error-dropdown">
</asp:RequiredFieldValidator>
</EditItemTemplate>
<FooterTemplate>
<asp:DropDownList ID="digvDDListServiceNameInsert" runat="server" ClientIDMode="Static" Enabled="false"
data-placeholder="Choose service…" class="chosen-single">
</asp:DropDownList>
<asp:RequiredFieldValidator ID="ReqValueDDLServiceNameInsert" runat="server" InitialValue="0"
ControlToValidate="digvDDListServiceNameInsert" ValidationGroup="InsertDeviceValidation"
ErrorMessage="Selection required." CssClass="message-error-dropdown">
</asp:RequiredFieldValidator>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Address">
<ItemTemplate>
<asp:Label ID="digvLblAddress" runat="server" Text='<%# Bind("Address") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="digvTxtBoxAddress" runat="server" Text='<%# Bind("Address") %>' Width="50%" ClientIDMode="Static"></asp:TextBox>
<asp:Label ID="digvEditAddressExt" runat="server" Visible="false" Text='<%# Bind("ServiceExtension") %>' Width="40%"
ClientIDMode="Static"></asp:Label>
<asp:RequiredFieldValidator ID="ReqValueAddressEdit" runat="server"
ControlToValidate="digvTxtBoxAddress" ValidationGroup="EditDeviceValidation"
ErrorMessage="Required field." CssClass="message-error">
</asp:RequiredFieldValidator>
<asp:CustomValidator ID="CustomValAddressEdit" runat="server" ControlToValidate="digvTxtBoxAddress" CssClass="message-error"
ErrorMessage="*" ClientValidationFunction="ValidateAddressEdit" EnableClientScript="true"
ValidationGroup="EditDeviceValidation" ></asp:CustomValidator>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="digvTxtBoxAddressInsert" runat="server" ClientIDMode="Static"></asp:TextBox>
<asp:RequiredFieldValidator ID="ReqValueAddressInsert" runat="server"
ControlToValidate="digvTxtBoxAddressInsert" ValidationGroup="InsertDeviceValidation"
ErrorMessage="Required field." CssClass="message-error">
</asp:RequiredFieldValidator>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Active">
<ItemTemplate>
<asp:Label ID="digvLblActive" runat="server" Text='<%# (Boolean.Parse(Eval("Active").ToString())) ? "Yes" : "No" %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:DropDownList ID="digvDDListActive" runat="server" Text='<%# (Boolean.Parse(Eval("Active").ToString())) ? "Yes" : "No" %>'>
<asp:ListItem>Yes</asp:ListItem>
<asp:ListItem>No</asp:ListItem>
</asp:DropDownList>
</EditItemTemplate>
<FooterTemplate>
<asp:DropDownList ID="digvDDListActiveInsert" runat="server">
<asp:ListItem Selected="True">Yes</asp:ListItem>
<asp:ListItem>No</asp:ListItem>
</asp:DropDownList>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Action" ShowHeader="False" ItemStyle-Wrap="false" ItemStyle-HorizontalAlign="Center">
<ItemTemplate>
<asp:Button ID="digvEditButton" runat="server" CausesValidation="True" CommandName="Edit"
Text="Edit" CssClass="gridActionbutton" ValidationGroup="EditDeviceValidation">
</asp:Button>
<asp:Button ID="digvDeleteButton" runat="server" CausesValidation="False" CommandName="Delete"
Text="Delete" CssClass="gridActionbutton" OnClientClick="return confirm('Are you sure you want to delete this Device Information?')" >
</asp:Button>
</ItemTemplate>
<EditItemTemplate>
<asp:Button ID="digvUpdateButton" runat="server" CausesValidation="True" ValidationGroup="EditDeviceValidation" CommandName="Update"
Text="Update" CssClass="gridActionbutton"></asp:Button>
<asp:Button ID="uigvCancelButton" runat="server" CausesValidation="False" CommandName="Cancel"
Text="Cancel" CssClass="gridActionbutton"></asp:Button>
</EditItemTemplate>
<FooterTemplate>
<asp:Button ID="digvAddButton" runat="server" CommandName="Add" Text="Add Device" Width="90%" CausesValidation="true"
CssClass="gridActionbutton" ValidationGroup="InsertDeviceValidation">
</asp:Button>
</FooterTemplate>
</asp:TemplateField>
</Columns>
<EmptyDataTemplate>
<tr>
<th>Device ID</th>
<th>Device</th>
<th>Service Provider</th>
<th>Address</th>
<th>Active</th>
<th>Action</th>
</tr>
<tr>
<td colspan="7" style="text-align:center;">
No Devices were found for you. Devices can be added by clicking the 'Add Device' Button.
</td>
</tr>
<tr>
<td></td>
<td>
<asp:DropDownList ID="digvDDListDeviceNameInsert" runat="server" ClientIDMode="Static"
data-placeholder="Choose device…" class="chosen-single">
</asp:DropDownList>
<asp:RequiredFieldValidator ID="ReqValueDDLDeviceNameEmpty" runat="server" InitialValue="0"
ControlToValidate="digvDDListDeviceNameInsert" ValidationGroup="InsertDeviceValidationEmpty"
ErrorMessage="Selection required." CssClass="message-error-dropdown">
</asp:RequiredFieldValidator>
</td>
<td>
<asp:DropDownList ID="digvDDListServiceNameInsert" runat="server" ClientIDMode="Static" Enabled="false"
data-placeholder="Choose service…" class="chosen-single">
</asp:DropDownList>
<asp:RequiredFieldValidator ID="ReqValueDDLServiceNameEmpty" runat="server" InitialValue="0"
ControlToValidate="digvDDListServiceNameInsert" ValidationGroup="InsertDeviceValidationEmpty"
ErrorMessage="Selection required." CssClass="message-error-dropdown">
</asp:RequiredFieldValidator>
</td>
<td>
<asp:TextBox ID="digvTxtBoxAddressInsert" runat="server" ClientIDMode="Static"></asp:TextBox>
<asp:RequiredFieldValidator ID="ReqValueAddressEmpty" runat="server"
ControlToValidate="digvTxtBoxAddressInsert" ValidationGroup="InsertDeviceValidationEmpty"
ErrorMessage="Required field." CssClass="message-error">
</asp:RequiredFieldValidator>
</td>
<td>
<asp:DropDownList ID="digvDDListActiveInsert" runat="server">
<asp:ListItem Selected="True">Yes</asp:ListItem>
<asp:ListItem>No</asp:ListItem>
</asp:DropDownList>
</td>
<td>
<asp:Button ID="digvAddButtonEmpty" runat="server" CommandName="Add" Text="Add Device" Width="90%" CausesValidation="true"
CssClass="gridActionbutton" ValidationGroup="InsertDeviceValidationEmpty">
</asp:Button>
</td>
</tr>
</EmptyDataTemplate>
</asp:GridView>
</div>
This is my current styling of the grid:
.grid
{background-color: #fff;
border: solid 2px #000;
border-collapse:collapse;
color: #FFF; overflow:auto
}
.grid td {
padding-left: 5px;
color: #000;
font-size: medium;
}
.grid th {
color: #000;
background: #99C3BB;
font-size: medium;
font-weight: bold;
}
.grid caption {
color: #000;
text-align:center;
font-weight:bold;
font-size:1.2em;
padding: 2px;
background-color: #99C3BB;
border: 2px solid black;
}
.grid table tr td {
color: #000;
font-size: small;
padding: 5px;
}
#DeviceGridWrapper
{
height: 250px;
width: 100%;
padding-bottom: 10px;
}
The column that is the problem is the 'Address' column. When only the textbox shows the width is set to '90%' programmatically. When the textbox and label are shown, the textbox is set to '50%' and the label is '40%'. They are side-by-side which is what I want. I need the Address column to widen to accomodate both of the controls so that the label does not extend into the next column.
Is there a way to set the Address column to a width that accomodates both controls?
Thanks.
Try using <EditRowStyle> element to the GridView::
<asp:GridView ID="GridView1" runat="server">
<EditRowStyle BackColor="Red" Width="100%" />
</asp:GridView>
Related
I have a parent grid GVInvoiceDet. CRUD operation on this grid is working fine. In each row of the parent, I have child grid GVTaxDetails which opens on click of image ie expand/collapse feature.
I am looking for CRUD within child grid also. But when I click on edit within child, the texbox for editing doesn't appear and the parent grid collapses.
Here is child grid rowediting code
protected void GVTaxDetails_RowEditing(object sender, GridViewEditEventArgs e)
{
GridView gvTemp = (GridView)sender;
gvUniqueID = gvTemp.UniqueID;
//gvEditIndex = e.NewEditIndex;
gvTemp.EditIndex = e.NewEditIndex;
GVInvoiceDet.DataBind();
}
Parent row editing code
protected void GVInvoiceDet_RowEditing(object sender, GridViewEditEventArgs e)
{
GVInvoiceDet.EditIndex = e.NewEditIndex;
GVInvoiceDet.DataBind();
BindItemGrid();
}
ASPX file :
<asp:GridView ID="GVInvoiceDet" runat="server" Width="100%" AutoGenerateColumns="False"
HorizontalAlign="Left" BorderStyle="Outset" OnRowCancelingEdit="GVInvoiceDet_RowCancelingEdit"
OnRowEditing="GVInvoiceDet_RowEditing" OnRowDataBound="GVInvoiceDet_RowDataBound" ShowFooter="True"
OnRowCommand="GVInvoiceDet_RowCommand" OnRowUpdating="GVInvoiceDet_RowUpdating"
OnRowDeleting="GVInvoiceDet_RowDeleting" OnRowDeleted="GVInvoiceDet_RowDeleted"
OnRowUpdated="GVInvoiceDet_RowUpdated" AllowSorting="True" DataSourceID="DSItemGrid" DataKeyNames="invoiceno,itemcd">
<HeaderStyle BackColor="#0000ff" ForeColor="Yellow" />
<FooterStyle BackColor="#FFFFCC" ForeColor="#330099" />
<EditRowStyle BackColor="#FFFFCC" ForeColor="#330099" />
<AlternatingRowStyle BackColor="#FE9CD5" />
<Columns>
<asp:TemplateField>
<ItemTemplate>
<a href="javascript:expandcollapse('div<%# Eval("itemcd") %>', 'one');">
<img id="imgdiv<%# Eval("itemcd") %>" alt="Click to show/hide Tax Details <%# Eval("itemcd") %>" border="0" src="Images/plus.png" />
</a>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField ItemStyle-Width="10%" HeaderText="Item Code" SortExpression="itemcd">
<ItemTemplate>
<asp:Label ID="lblItemCode" runat="server" Text='<%# Eval("itemcd")%>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtItemCode" Width="90%" runat="server" Text='<%# Eval("itemcd")%>' Enabled="false"></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtItemCode" Width="90%" runat="server" Text='' Enabled="false"></asp:TextBox>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField ItemStyle-Width="10%" HeaderText="HSN Code" SortExpression="hsncd">
<ItemTemplate>
<asp:Label ID="lblItemHSNCode" runat="server" Text='<%# Eval("hsncd")%>'></asp:Label><asp:HiddenField ID="hdnItemGST" runat="server" Value='<%# Eval("itempercentage") %>' />
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtItemHSN" Width="90%" runat="server" Text='<%# Eval("hsncd")%>' Enabled="false"></asp:TextBox><asp:HiddenField ID="hdnEditItemGST" runat="server" Value='<%# Eval("itempercentage") %>' />
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtItemHSN" Width="90%" runat="server" Text='' Enabled="false"></asp:TextBox><asp:HiddenField ID="hdnFooterItemGST" runat="server" Value='<%# Eval("itempercentage") %>' />
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField ItemStyle-Width="25%" HeaderText="Item Description" SortExpression="itemdesc">
<ItemTemplate>
<asp:Label ID="lblItemDesc" runat="server" Text='<%# Eval("itemdesc")%>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:Label ID="lblItemDesc" runat="server" Text='<%# Eval("itemdesc")%>' Visible="false"></asp:Label><asp:HiddenField ID="hdnItemDesc" runat="server" Value='<%# String.Format("{0}-{1}-{2}",Eval("itemcd"),Eval("hsncd"),Eval("itempercentage")) %>' />
<asp:DropDownList ID="eddlItemDesc" runat="server" AutoPostBack="true" OnSelectedIndexChanged="eddlItemDesc_SelectedIndexChanged"></asp:DropDownList>
</EditItemTemplate>
<FooterTemplate>
<asp:DropDownList ID="fddlItemDesc" runat="server" AutoPostBack="true" OnSelectedIndexChanged="fddlItemDesc_SelectedIndexChanged"></asp:DropDownList>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField ItemStyle-Width="5%" HeaderText="Quantity">
<ItemTemplate>
<asp:Label ID="lblItemQty" runat="server" Text='<%# Eval("quantity")%>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtItemQty" Width="90%" runat="server" Text='<%# Eval("quantity")%>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtItemQty" Width="90%" MaxLength="100" runat="server"></asp:TextBox>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField ItemStyle-Width="5%" HeaderText="Unit Rate">
<ItemTemplate>
<asp:Label ID="lblItemUnitRate" runat="server" Text='<%# Eval("unitrate")%>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtItemUnitRate" Width="90%" runat="server" Text='<%# Eval("unitrate")%>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtItemUnitRate" Width="90%" MaxLength="100" runat="server"></asp:TextBox>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField ItemStyle-Width="5%" HeaderText="Unit Value">
<ItemTemplate>
<asp:Label ID="lblItemUnitValue" runat="server" Text='<%# Eval("unitvalue")%>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtItemUnitValue" Width="90%" runat="server" Text='<%# Eval("unitvalue")%>' Enabled="false"></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtItemUnitValue" Width="90%" MaxLength="100" runat="server" Enabled="false"></asp:TextBox>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField ItemStyle-Width="5%" HeaderText="Final Value">
<ItemTemplate>
<asp:Label ID="lblItemFinalValue" runat="server" Text=''></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtItemFinalValue" Width="90%" runat="server" Text='' Enabled="false"></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtItemFinalValue" Width="90%" MaxLength="100" runat="server" Enabled="false"></asp:TextBox>
</FooterTemplate>
</asp:TemplateField>
<asp:CommandField ShowEditButton="True" HeaderText="Edit" />
<asp:TemplateField HeaderText="Delete" ItemStyle-Width="5%">
<ItemTemplate>
<asp:LinkButton ID="linkDeleteInvoiceItem" CommandName="DeleteItem" runat="server">Delete</asp:LinkButton>
</ItemTemplate>
<FooterTemplate>
<asp:LinkButton ID="linkAddInvoiceItem" CommandName="AddItem" runat="server">Add</asp:LinkButton>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<tr>
<td colspan="100%">
<div id="div<%# Eval("itemcd") %>" style="display: none; position: relative; left: 15px; overflow: auto; width: 97%">
<asp:GridView ID="GVTaxDetails" BackColor="White" Width="100%" Font-Size="Small" AutoGenerateColumns="false"
runat="server" DataKeyNames="invoiceno,itemcd,valuecd" ShowFooter="True" OnRowUpdating="GVTaxDetails_RowUpdating"
OnRowCommand="GVTaxDetails_RowCommand" OnRowEditing="GVTaxDetails_RowEditing" GridLines="None"
OnRowUpdated="GVTaxDetails_RowUpdated" OnRowCancelingEdit="GVTaxDetails_CancelingEdit"
OnRowDataBound="GVTaxDetails_RowDataBound" OnRowDeleting="GVTaxDetails_RowDeleting" OnRowDeleted="GVTaxDetails_RowDeleted"
ShowHeaderWhenEmpty="true" BorderStyle="Double" BorderColor="#0083C1">
<RowStyle BackColor="Gainsboro" />
<AlternatingRowStyle BackColor="White" />
<HeaderStyle BackColor="#0083C1" ForeColor="White" />
<FooterStyle BackColor="White" />
<Columns>
<asp:TemplateField ItemStyle-Width="5%" HeaderText="SL No">
<ItemTemplate>
<asp:Label ID="lblViewTaxSlno" runat="server" Text='<%# Eval("slno")%>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtViewTaxSlno" runat="server" Text='<%# Eval("slno")%>' Enabled="false"></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtViewTaxSlno" MaxLength="3" Width="80%" runat="server" Text='<%# Convert.ToInt32(Container.DataItemIndex) + 1 %>' Enabled="false"></asp:TextBox>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField ItemStyle-Width="15%" HeaderText="Value">
<ItemTemplate>
<asp:HiddenField ID="hdnViewTaxDesc" runat="server" Value='<%# Eval("valuecd") %>' />
<asp:Label ID="lblViewTaxDesc" runat="server" Text='<%# Eval("valuedesc")%>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:HiddenField ID="hdnViewTaxDesc" runat="server" Value='<%# Eval("valuecd") %>' />
<asp:DropDownList ID="eddlViewTaxDesc" Width="90%" runat="server" AutoPostBack="true" OnSelectedIndexChanged="eddViewTaxDesc_SelectedIndexChanged"></asp:DropDownList>
</EditItemTemplate>
<FooterTemplate>
<asp:HiddenField ID="hdnViewTaxDesc" runat="server" Value='<%# Eval("valuecd") %>' />
<asp:DropDownList ID="fddViewTaxDesc" Width="90%" runat="server" OnSelectedIndexChanged="fddlViewTaxDesc_SelectedIndexChanged"></asp:DropDownList>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField ItemStyle-Width="3%" HeaderText="Amount">
<ItemTemplate>
<asp:Label ID="lblViewTaxAmount" runat="server" Text='<%# Eval("value")%>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtViewTaxAmount" runat="server" Text='<%# Eval("value")%>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtViewTaxAmount" runat="server" Text='<%# Eval("value")%>'></asp:TextBox>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField ItemStyle-Width="7%" HeaderText="Ref. Sl No">
<ItemTemplate>
<asp:Label ID="lblViewTaxRefNo" runat="server" Text='<%# Eval("refslno")%>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:HiddenField ID="hdnViewTaxRefNo" runat="server" Value='<%# Eval("refslno") %>' />
<asp:DropDownList ID="eddlViewTaxRefNo" Width="90%" runat="server" AutoPostBack="false"></asp:DropDownList>
</EditItemTemplate>
<FooterTemplate>
<asp:DropDownList ID="fddViewTaxRefNo" Width="90%" runat="server" AutoPostBack="false"></asp:DropDownList>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField ItemStyle-Width="10%" HeaderText="Tax-Mode">
<ItemTemplate>
<asp:Label ID="lblViewTaxMode" runat="server" Text='<%# Eval("absper").ToString()=="A"?"Absolute":"Percentage"%>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:HiddenField ID="hdnViewTaxMode" runat="server" Value='<%# Eval("absper") %>' />
<asp:DropDownList ID="eddlViewTaxMode" Width="90%" runat="server" AutoPostBack="false">
<asp:ListItem Value="-1" Text="-Select Mode-" Selected="True"></asp:ListItem>
<asp:ListItem Value="A" Text="Absolute"></asp:ListItem>
<asp:ListItem Value="P" Text="Percentage"></asp:ListItem>
</asp:DropDownList>
</EditItemTemplate>
<FooterTemplate>
<asp:DropDownList ID="fddlViewTaxMode" Width="95%" runat="server" AutoPostBack="false">
<asp:ListItem Value="-1" Text="-Select Mode-" Selected="True"></asp:ListItem>
<asp:ListItem Value="A" Text="Absolute"></asp:ListItem>
<asp:ListItem Value="P" Text="Percentage"></asp:ListItem>
</asp:DropDownList>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField ItemStyle-Width="10%" HeaderText="Operation">
<ItemTemplate>
<asp:Label ID="lblViewTaxOperation" runat="server" Text='<%# Eval("addsub").ToString()=="A"?"Add":"Subtract"%>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:HiddenField ID="hdnViewTaxOperation" runat="server" Value='<%# Eval("addsub") %>' />
<asp:DropDownList ID="eddlViewTaxOperation" Width="90%" runat="server" AutoPostBack="false">
<asp:ListItem Value="-1" Text="-Select Operation-" Selected="True"></asp:ListItem>
<asp:ListItem Value="A" Text="Add"></asp:ListItem>
<asp:ListItem Value="S" Text="Subtract"></asp:ListItem>
</asp:DropDownList>
</EditItemTemplate>
<FooterTemplate>
<asp:DropDownList ID="fddlViewTaxOperation" Width="90%" runat="server" AutoPostBack="false">
<asp:ListItem Value="-1" Text="-Select Operation-" Selected="True"></asp:ListItem>
<asp:ListItem Value="A" Text="Add"></asp:ListItem>
<asp:ListItem Value="S" Text="Subtract"></asp:ListItem>
</asp:DropDownList>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField ItemStyle-Width="3%" HeaderText="Final Amount">
<ItemTemplate>
<asp:Label ID="lblViewTaxFinalAmount" runat="server" Text='<%# Eval("finalvalue")%>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtViewTaxFinalAmount" runat="server" Text='<%# Eval("finalvalue")%>' Enabled="false"></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtViewTaxFinalAmount" runat="server" Text='<%# Eval("finalvalue")%>' Enabled="false"></asp:TextBox>
</FooterTemplate>
</asp:TemplateField>
<asp:CommandField HeaderText="Edit" ShowEditButton="True" />
<asp:TemplateField HeaderText="Delete">
<ItemTemplate>
<asp:LinkButton ID="linkDeleteTaxDetails" CommandName="Delete" runat="server">Delete</asp:LinkButton>
</ItemTemplate>
<FooterTemplate>
<asp:LinkButton ID="linkAddTaxDetails" CommandName="AddTax" runat="server">Add</asp:LinkButton>
</FooterTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
</td>
</tr>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="DSItemGrid" runat="server" ConnectionString="<%$ ConnectionStrings:GSTCS %>" ProviderName="<%$ ConnectionStrings:GSTCS.ProviderName %>"
SelectCommand="select invoiceno, dt.itemcd itemcd, mast.itemdesc itemdesc, mast.hsncd hsncd, dt.quantity quantity,
mast.unitrate unitrate, dt.unitvalue unitvalue, mast.itempercentage itempercentage
from GSTINVOICEDT dt join GSTITEMMASTER mast on (dt.itemcd = mast.itemcd and dt.unitcode = mast.unitcode and dt.projectcode = mast.projectcode)
where dt.unitcode = :unitCode and dt.projectCode = :projCode and dt.invoiceno = :invoiceNo order by invoiceno, itemcd">
<SelectParameters>
<asp:SessionParameter DefaultValue="05" Name="unitCode" SessionField="unit" />
<asp:SessionParameter DefaultValue="0501" Name="projCode" SessionField="project" />
<asp:SessionParameter DefaultValue="INVOICENO" Name="invoiceNo" SessionField="invoiceNo" Type="String" />
</SelectParameters>
</asp:SqlDataSource>
I got the work done... Posting the code for others if come across similar situation.
In parent rowdatabound have added code to keep the div open and update the editIndex.
protected void GVInvoiceDet_RowDataBound(object sender, GridViewRowEventArgs e) {
GridViewRow row = e.Row;
if(row.RowType == DataControlRowType.Header)
{
return;
}
else if (row.RowType == DataControlRowType.DataRow )
{
//Find Child GridView control
GridView gvTax = new GridView();
gvTax = (GridView)row.FindControl("GVTaxDetails");
if (gvTax.UniqueID == gvUniqueID)
{
gvTax.EditIndex = gvEditIndex;
//Expand the Child grid
ClientScript.RegisterStartupScript(GetType(), "Expand", "<SCRIPT LANGUAGE='javascript'>expandcollapse('div" + ((DataRowView)e.Row.DataItem)["itemcd"].ToString() + "','one');</script>");
}
}
}
expandcollapse is function on aspx side:
function expandcollapse(obj, row) {
var div = document.getElementById(obj);
var img = document.getElementById('img' + obj);
if (div.style.display == "none") {
div.style.display = "block";
if (row == 'alt') {
img.src = "Images/minus.png";
}
else {
img.src = "Images/minus.png";
}
img.alt = "Close View Taxes";
}
else {
div.style.display = "none";
if (row == 'alt') {
img.src = "Images/plus.png";
}
else {
img.src = "Images/plus.png";
}
img.alt = "Expand View Taxes";
}
}
I have a nested GridView to 5 levels and I am having hard time accessing which RadioButtonList is selected in 2nd level of GridView. (first level is named gvSecondLevel so please don't get confused). I have to now access from gvThirdLevel (which is actually 2nd level grid as you will see in code). I am not sure whether the issue is with ASPX code or c# code. I have tried putting rbThirdLevel inside TemplateField and without it. But I can't access it either way. Here is the aspx code:
<table align="left">
<tr>
<td colspan="2">
<asp:GridView ID="gvSecondLevel" runat="server" AutoGenerateColumns="False" Width="800px"
ShowFooter="True" BorderStyle="none" DataKeyNames="CallCategory_ID" OnRowDataBound="gvSecondLevel_OnRowDataBound"
OnRowCommand="gvSecondLevel_RowCommand" OnRowDeleting="gv_RowDeleting" AllowPaging="true"
PageSize="10" OnPageIndexChanging="gvSecondLevel_PageIndexChanging" OnRowCreated="gvSecondLevel_RowCreated" >
<Columns>
<asp:TemplateField HeaderText="ID" HeaderStyle-Width="20px">
<ItemTemplate>
<asp:Label ID="lblBusinessID" runat="server" Text='<%#DataBinder.Eval(Container.DataItem,"CallCategory_ID") %>'></asp:Label>
</ItemTemplate>
<HeaderStyle Width="20px" />
</asp:TemplateField>
<asp:BoundField DataField="CallCategory_Name" HeaderText="Call Category Name 2nd" />
<asp:TemplateField HeaderText="" ItemStyle-Width="20px">
<ItemTemplate>
<asp:LinkButton ID="lbtnDeleteSecondLevel" CommandArgument='<%# Eval("CallCategory_ID") %>'
CommandName="Delete" runat="server"></asp:LinkButton>
</ItemTemplate>
<ItemStyle Width="20px" />
</asp:TemplateField>
<asp:TemplateField HeaderStyle-BorderStyle="None" FooterStyle-BorderStyle="None"
ItemStyle-BorderStyle="None">
<ItemTemplate>
<tr>
<td id="td_div<%# Eval("CallCategory_ID") %>" colspan="100%" style="border: none;">
<div id="div<%# Eval("CallCategory_ID") %>" style="overflow: auto; display: none;
position: relative; left: 15px; overflow: auto">
<asp:GridView ID="gvThirdLevel" runat="server" Width="95%" AutoGenerateColumns="false"
ShowFooter="true" BorderStyle="none" DataKeyNames="CallCategory_ID" OnRowDataBound="gvThirdLevel_OnRowDataBound"
OnRowCommand="gvThirdLevel_RowCommand" OnRowDeleting="gv_RowDeleting">
<Columns>
<asp:TemplateField HeaderText="ID" Visible="true" HeaderStyle-Width="20px">
<ItemTemplate>
<asp:Label ID="lblCallCategoryID" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "CallCategory_ID") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="CallCategory_Name" HeaderText="Call Category Name 3rd" />
<asp:TemplateField HeaderText="" ItemStyle-Width="20px">
<ItemTemplate>
<asp:LinkButton ID="lbtnDeleteThirdLevel" CommandArgument='<%# Eval("CallCategory_ID") %>'
CommandName="Delete" runat="server">Deactivate</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderStyle-BorderStyle="None" FooterStyle-BorderStyle="None"
ItemStyle-BorderStyle="None">
<ItemTemplate>
<tr>
<td id="td_div1<%# Eval("CallCategory_ID") %>" colspan="100%" style="border: none;">
<div id="div1<%# Eval("CallCategory_ID") %>" style="overflow: auto; display: none;
position: relative; left: 15px; overflow: auto">
<asp:GridView ID="gvFourthLevel" runat="server" Width="95%" AutoGenerateColumns="false"
BorderStyle="none" ShowFooter="true" OnRowDataBound="gvFourthLevel_OnRowDataBound"
OnRowCommand="gvFourthLevel_RowCommand" OnRowDeleting="gv_RowDeleting" DataKeyNames="CallCategory_ID">
<Columns>
<asp:TemplateField HeaderText="ID" HeaderStyle-Width="20px">
<ItemTemplate>
<asp:Label ID="lblCallCategoryID_Fourth" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "CallCategory_ID") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="CallCategory_Name" HeaderText="Call Category Name 4th" />
<asp:TemplateField HeaderText="" ItemStyle-Width="20px">
<ItemTemplate>
<asp:LinkButton ID="lbtnDeleteFourthLevel" CommandArgument='<%# Eval("CallCategory_ID") %>'
CommandName="Delete" runat="server">Deactivate</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderStyle-BorderStyle="None" FooterStyle-BorderStyle="None"
ItemStyle-BorderStyle="None">
<ItemTemplate>
<tr>
<td id="td_div2<%# Eval("CallCategory_ID") %>" colspan="100%" style="border: none;">
<div id="div2<%# Eval("CallCategory_ID") %>" style="overflow: auto; display: none;
position: relative; left: 15px; overflow: auto">
<asp:GridView ID="gvFifthLevel" runat="server" Width="95%" AutoGenerateColumns="false"
BorderStyle="none" ShowFooter="true" OnRowDataBound="gvFifthLevel_OnRowDataBound"
OnRowCommand="gvFifthLevel_RowCommand" OnRowDeleting="gv_RowDeleting" DataKeyNames="CallCategory_ID">
<Columns>
<asp:TemplateField HeaderText="ID" HeaderStyle-Width="20px">
<ItemTemplate>
<asp:Label ID="lblCallCategoryID_Fifth" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "CallCategory_ID") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="CallCategory_Name" HeaderText="Call Category Name 5th" />
<asp:TemplateField HeaderText="" ItemStyle-Width="20px">
<ItemTemplate>
<asp:LinkButton ID="lbtnDeleteFifthLevel" CommandArgument='<%# Eval("CallCategory_ID") %>'
CommandName="Delete" runat="server">Deactivate</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderStyle-BorderStyle="None" FooterStyle-BorderStyle="None"
ItemStyle-BorderStyle="None">
<ItemTemplate>
<tr>
<td id="td_div3<%# Eval("CallCategory_ID") %>" colspan="100%" style="border: none;">
<div id="div3<%# Eval("CallCategory_ID") %>" style="overflow: auto; display: none;
position: relative; left: 15px; overflow: auto">
<asp:GridView ID="gvSixthLevel" runat="server" Width="95%" AutoGenerateColumns="false"
BorderStyle="none" ShowFooter="true" OnRowDataBound="gvSixthLevel_OnRowDataBound"
OnRowCommand="gvSixthLevel_RowCommand" OnRowDeleting="gv_RowDeleting">
<Columns>
<asp:BoundField DataField="CallCategory_ID" HeaderText="ID" HeaderStyle-Width="20px" />
<asp:BoundField DataField="CallCategory_Name" HeaderText="Call Category Name 6th" />
<asp:TemplateField HeaderText="" ItemStyle-Width="20px">
<ItemTemplate>
<asp:LinkButton ID="lbtnDeleteSixthLevel" CommandArgument='<%# Eval("CallCategory_ID") %>'
CommandName="Delete" runat="server">Deactivate</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:RadioButtonList ID="rbSixthLevel" runat="server"
onselectedindexchanged="rbSixthLevel_SelectedIndexChanged" RepeatDirection="Horizontal" AutoPostBack="True">
<asp:ListItem Selected="True">Active</asp:ListItem>
<asp:ListItem>Inactive</asp:ListItem>
</asp:RadioButtonList>
</div>
</td>
</tr>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:RadioButtonList ID="rbFifthLevel" runat="server" onselectedindexchanged="rbFifthLevel_SelectedIndexChanged" RepeatDirection="Horizontal" AutoPostBack="True">
<asp:ListItem Selected="True">Active</asp:ListItem>
<asp:ListItem>Inactive</asp:ListItem>
</asp:RadioButtonList>
</td>
</tr>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:RadioButtonList ID="rbFourthLevel" runat="server" onselectedindexchanged="rbFourthLevel_SelectedIndexChanged" RepeatDirection="Horizontal" AutoPostBack="True">
<asp:ListItem Selected="True">Active</asp:ListItem>
<asp:ListItem>Inactive</asp:ListItem>
</asp:RadioButtonList>
</div>
</td>
</tr>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:TemplateField>
<ItemTemplate>
<asp:RadioButtonList ID="rbThirdLevel" runat="server" onselectedindexchanged="rbThirdLevel_SelectedIndexChanged" RepeatDirection="Horizontal" AutoPostBack="True">
<asp:ListItem Selected="True">Active</asp:ListItem>
<asp:ListItem>Inactive</asp:ListItem>
</asp:RadioButtonList>
</ItemTemplate>
</asp:TemplateField>
</div>
</td>
</tr>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:RadioButtonList ID="rbSecondLevel" runat="server" onselectedindexchanged="rbSecondLevel_SelectedIndexChanged"
RepeatDirection="Horizontal" AutoPostBack="True">
<asp:ListItem Selected="True">Active</asp:ListItem>
<asp:ListItem>Inactive</asp:ListItem>
</asp:RadioButtonList>
</td>
</tr>
</table>
C# code is just return "Active" even when I select "Inactive". Please guide what is the correct way to access rbThirdLevel
protected void rbThirdLevel_SelectedIndexChanged(object sender, EventArgs e)
{
foreach (GridViewRow row in gvSecondLevel.Rows)
{
if (row.RowType == DataControlRowType.DataRow)
{
GridView gvThirdLevel = (GridView)row.FindControl("gvThirdLevel");
if (gvThirdLevel != null)
{
RadioButtonList rbThirdLevel = gvSecondLevel.Rows[row.RowIndex].FindControl("rbThirdLevel") as RadioButtonList;
string radiovalue = (gvSecondLevel.Rows[row.RowIndex].FindControl("rbThirdLevel") as RadioButtonList).SelectedItem.Value;
if (rbThirdLevel.SelectedValue == "Inactive")
{
//code to display Deactivated rows
}
if (rbThirdLevel.SelectedValue == "Active")
{
//code to display Activated rows
}
}
}
}
}
how can i get selected value of dropdownlist on nested gridview row command.
I have a nested gridview in my page, inside of second gridview i want to use a drop down list for Driver. I am trying to get the selected value for that drop down list but unable to got it in gridview rowcommand. i try button click event also but i am unable to got it.
<asp:GridView ID="dtgNewTrips" runat="server" AllowPaging="true" AutoGenerateColumns="false" CssClass="table table-striped table-bordered table-hover" OnRowDataBound="dtgNewTrips_RowDataBound" DataKeyNames="Trips_ID">
<Columns>
<asp:TemplateField ItemStyle-Width="20px">
<ItemTemplate>
<a href="JavaScript:ViewDetails('div<%# Eval(" Trips_ID ") %>');">
<img alt="City" id="imgdiv<%# Eval("Trips_ID") %>" src="Images/Icons/plusicon.png" />
</a>
<div id="div<%# Eval(" Trips_ID ") %>" style="display: none;">
<asp:GridView ID="dtgViewDetails" runat="server" AutoGenerateColumns="false" DataKeyNames="Trips_ID" CssClass="ChildGrid" ShowHeader="false" OnRowDataBound="dtgViewDetails_RowDataBound" OnRowCommand="dtgViewDetails_RowCommand">
<Columns>
<asp:TemplateField ShowHeader="false">
<ItemTemplate>
<div>
<table style="width: 100%;">
<tr>
<td>Adults:
<asp:Label ID="lblTrip_ID" runat="server" Text='<%#Eval("Trips_ID") %>' Visible="false"></asp:Label>
<asp:Label ID="Label1" runat="server" Text='<%#Eval("AdultsCount") %>'></asp:Label>
</td>
<td>Children:
<asp:Label ID="Label2" runat="server" Text='<%#Eval("ChildrensCount") %>'></asp:Label>
</td>
<td>Passenger Comments:
<asp:Label ID="Label4" runat="server" Text='<%#Eval("PassengerComments") %>'></asp:Label>
</td>
</tr>
<tr>
<td>Trip Stops:</td>
<td>
<asp:Label ID="Label3" runat="server" Text='<%#Eval("TripStops") %>'></asp:Label>
</td>
<td>TripStops Comments:
<asp:Label ID="Label5" runat="server" Text='<%#Eval("TripStopsComments") %>'></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:DropDownList ID="ddlDriver" runat="server" DataTextField="DriverName" DataValueField="DriversInfo_ID" CssClass="form-control" AutoPostBack="false"></asp:DropDownList>
</ContentTemplate>
</asp:UpdatePanel>
</td>
<td>
<asp:Button ID="btnAssign" runat="server" Text="Assign To Driver" CssClass="btn btn-primary" CommandArgument='<%# ((GridViewRow)Container).RowIndex %>' CommandName="Assign" />
</td>
<td>
<asp:Button ID="btnAssignToAll" runat="server" OnClick="btnAssignToAll_Click" Text="Notify All Drivers" CssClass="btn btn-primary" />
<asp:Button ID="btnCancelTrip" runat="server" OnClick="btnCancelTrip_Click" Text="Cancel Trip" CssClass="btn btn-warning" />
</td>
</tr>
</table>
</div>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Trip No">
<ItemTemplate>
<asp:Label ID="lblTripRefID" runat="server" Text='<%#Eval("TripRefID") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Customer Name">
<ItemTemplate>
<asp:Label ID="lblCompanyName" runat="server" Text='<%#Eval("CompanyName") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Pickup Location">
<ItemTemplate>
<asp:Label ID="lblPickupLocation" runat="server" Text='<%#Eval("PickupLocation") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
C# Code
protected void dtgViewDetails_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Assign")
{
int rowIndex = Convert.ToInt32(e.CommandArgument);
GridView grid = (GridView)sender;
if (grid.ID == "dtgViewDetails")
{
Label lblTrip_ID = (Label)grid.Rows[rowIndex].FindControl("lblTrip_ID");
DropDownList ddlDriver = (DropDownList)grid.Rows[rowIndex].FindControl("ddlDriver");
}
}
}
But i get the by default of dropdownlist that zeroth index value.
please help me..
thanks in advance..
I am using 2 link buttons (Coordinator and Staff) which on_Click action displays corresponding panels asking for login/signup/forgotpassword. If the user select signup/forgotpassword a popup windows is popped (using ModalPopupExtender) asking for information. Everything worked fine unless and until I used required field validator within the panel which pops up when the user click on signup/forgotpassword. If I use required field validator my page run fine and when I click on any of the link button (Coordinator/Staff) nothing happens.
This is aspx code :
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type = "text/css">
.modalBackground
{
background-color: gray;
}
.modalPopup
{
background-color: white;
border-width: 3px;
border-style: solid;
border-color: black;
padding-top: 10px;
padding-left: 10px;
width: 300px;
height: 140px;
}
.panel
{
background : gray;
padding : 10px;
}
div ul ul
{
display: none;
}
div ul li:hover > ul
{
display: block;
}
div ul li ul:hover > ul
{
display: block;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="Label1" runat="server" Font-Bold="True" Font-Names="Arial" Font-Size="XX-Large" Text="Automated Examination System"></asp:Label><br /> <br /><br />
<asp:Panel ID = "MainPanel" runat = "server" Height="181px" Width="275px">
<ul>
<li style="margin-left: 33px; width: 169px;"> <asp:LinkButton ID = "LinkAdmin" runat = "server" onclick="LinkAdmin_Click">Coordinator</asp:LinkButton></li>
<li style="width: 172px; margin-left: 33px"> <asp:LinkButton ID="LinkStaff" runat="server" onclick="LinkStaff_Click">Staff</asp:LinkButton></li>
<li style="margin-left: 33px"> <asp:LinkButton ID = "LinkStudent" runat = "server">Student</asp:LinkButton>
<ul>
<li><asp:LinkButton ID = "LinkButton1" runat = "server">Fresh Registration</asp:LinkButton></li>
<li><asp:LinkButton ID = "LinkButton2" runat = "server">Re Registration</asp:LinkButton></li>
</ul>
</li>
</ul>
</asp:Panel>
<asp:Panel ID="InfoPanel" runat="server" style="left: 290px; top: 104px; position: absolute; height: 375px; width: 611px"><br /><br /><br />
<asp:Label ID="Label2" runat="server" Font-Bold="False" Font-Names="Arial" Font-Size="Medium" Text="The Automated Examination system will allow post graduation student and under graduation students to register their respective courses for their respective semester. "></asp:Label>
<asp:Label ID="Label3" runat="server" Font-Bold="False" Font-Names="Arial" Font-Size="Medium" Text="Once the registration process is completed for a student the system sends information to the controller of examination."></asp:Label><br />
<asp:Label ID="Label4" runat="server" Font-Bold="False" Font-Names="Arial" Font-Size="Medium" Text="Each staff will be able to enter the CIE1 and CIE2 marks based on the privileges provided by coordinator of that respective department. "></asp:Label><br />
<asp:Label ID="Label5" runat="server" Font-Bold="False" Font-Names="Arial" Font-Size="Medium" Text="Once the staff enters marks for CIE1/CIE2, they won’t be allowed to make changes later on. "></asp:Label><br />
<asp:Label ID="Label6" runat="server" Font-Bold="False" Font-Names="Arial" Font-Size="Medium" Text="After submitting the marks, the staff will be given with print out of the entered marks for further reference. "></asp:Label><br />
<asp:Label ID="Label7" runat="server" Font-Bold="False" Font-Italic="False" Font-Names="Arial" Font-Size="Medium" Text="At the end of a semester each student SGPA is calculated and the controller take a back up copy of grade cards and result sheet of all the students. "></asp:Label><br />
<asp:Label ID="Label9" runat="server" Font-Bold="False" Font-Names="Arial" Font-Size="Medium" Text="Since student grades are sensitive information certain measures are taken to prevent unauthorized access. "></asp:Label><br />
<asp:Label ID="Label8" runat="server" Font-Bold="False" Font-Names="Arial" Font-Size="Medium" Text="The system also generate the transcript of student which contains all semester marks, Course Title in that particular semester, SGPA of each semester and overall CGPA of that student. "></asp:Label>
</asp:Panel>
<asp:Panel ID="AdminLogin" runat="server" style= "left: 906px; top: 105px; position: absolute; " Visible="False" Width="430px"><br/>
<asp:Label ID="Label10" runat="server" Text="Coordinator Login"></asp:Label><br /><br />
<asp:Label ID="Label11" runat="server" Text="Select Department : "></asp:Label>
<asp:DropDownList ID="DropDownList1" runat="server" ValidationGroup="AdminLogin"></asp:DropDownList>
<asp:RequiredFieldValidator ID="AdminReq1" runat="server" ControlToValidate="DropDownList1" ErrorMessage="Department is blank" ForeColor="Red" ValidationGroup="AdminLogin"></asp:RequiredFieldValidator><br /><br />
<asp:Label ID="Label12" runat="server" Text="Select Branch : "></asp:Label>
<asp:DropDownList ID="DropDownList2" runat="server" ValidationGroup="AdminLogin"></asp:DropDownList>
<asp:RequiredFieldValidator ID="AdminReq2" runat="server" ControlToValidate="DropDownList2" ErrorMessage="Branch is blank" ForeColor="Red" ValidationGroup="AdminLogin"></asp:RequiredFieldValidator><br /><br />
<asp:Label ID="Label13" runat="server" Text="Username : "></asp:Label>
<asp:TextBox ID="AdminTxt1" runat="server" ValidationGroup="AdminLogin" style="height: 22px"></asp:TextBox>
<asp:RequiredFieldValidator ID="AdminReq3" runat="server" ControlToValidate="AdminTxt1" ErrorMessage="Username is blank" ForeColor="Red" ValidationGroup="AdminLogin"></asp:RequiredFieldValidator><br /><br />
<asp:Label ID="Label14" runat="server" Text="Password : "></asp:Label>
<asp:TextBox ID="AdminTxt2" runat="server" TextMode="Password" ValidationGroup="AdminLogin"></asp:TextBox>
<asp:RequiredFieldValidator ID="AdminReq4" runat="server" ControlToValidate="AdminTxt2" ErrorMessage="Password is blank" ForeColor="Red" ValidationGroup="AdminLogin"></asp:RequiredFieldValidator><br /><br />
<asp:Button ID="AdminLog" runat="server" Text="Login" Width="80px" ValidationGroup="AdminLogin" />
<asp:Button ID="AdminSignUp" runat="server" Text="New Coordinator" Width="110px"/>
<asp:Button ID="AdminForPwd" runat="server" Text="Forgot Password" />
</asp:Panel>
<asp:Panel ID="StaffLogin" runat="server" style="left: 906px; top: 105px; position: absolute;" Visible="False" Width="430px"><br />
<asp:Label ID="Label15" runat="server" Text="Staff Login"></asp:Label><br /><br />
<asp:Label ID="Label16" runat="server" Text="Username : "></asp:Label>
<asp:TextBox ID="StaffTxt1" runat="server" Width="127px" ValidationGroup="StaffLogin"></asp:TextBox>
<asp:RequiredFieldValidator ID="StaffReq1" runat="server" ControlToValidate=" StaffTxt1" ErrorMessage="Username is blank" ForeColor="Red" ValidationGroup="StaffLogin"></asp:RequiredFieldValidator><br /><br />
<asp:Label ID="Label17" runat="server" Text="Password : "></asp:Label>
<asp:TextBox ID="StaffTxt2" runat="server" TextMode="Password" ValidationGroup="StaffLogin"></asp:TextBox>
<asp:RequiredFieldValidator ID="StaffReq2" runat="server" ControlToValidate=" StaffTxt2" ErrorMessage="Password is blank" ForeColor="Red" ValidationGroup="StaffLogin"></asp:RequiredFieldValidator><br /><br />
<asp:Button ID="StaffLog" runat="server" Text="Login" Width="80px" ValidationGroup="StaffLogin" />
<asp:Button ID="StaffSignUp" runat="server" Text="New Staff" Width="82px"/>
<asp:Button ID="StaffForPwd" runat="server" Text="Forgot Password" Width="110px" />
</asp:Panel>
<asp:Panel ID="StaffSP" CssClass="modalPopup" style="display: none" runat="server">
<asp:Label ID="Label18" runat="server" Text="Staff Sign Up" Font-Size="XX-Large"></asp:Label><br /><br />
<asp:Label ID="Label19" runat="server" Text="Enter Course Code : "></asp:Label>
<asp:TextBox ID="StaffSPTxt1" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="StaffSPReq1" runat="server" ErrorMessage="Course Code is BLANK" ForeColor="Red" ControlToValidate="StaffSPTxt1"></asp:RequiredFieldValidator><br /><br />
<asp:Label ID="Label20" runat="server" Text="Enter Password : "></asp:Label>
<asp:TextBox ID="StaffSPTxt2" runat="server" TextMode="Password"></asp:TextBox>
<asp:RequiredFieldValidator ID="StaffSPReq2" runat="server" ErrorMessage="Password is BLANK" ForeColor="Red" ControlToValidate="StaffSPTxt2"></asp:RequiredFieldValidator><br /><br />
<asp:Label ID="Label21" runat="server" Text="Retype Password : "></asp:Label>
<asp:TextBox ID="StaffSPTxt3" runat="server" TextMode="Password"></asp:TextBox>
<asp:CompareValidator ID="StaffSPCom1" runat="server" ErrorMessage="Password Mismatch" ForeColor="Red" ControlToCompare="StaffSPTxt2" ControlToValidate="StaffSPTxt3"></asp:CompareValidator><br /><br />
<asp:Label ID="Label22" runat="server" Text="Enter Password Hint : "></asp:Label>
<asp:TextBox ID="StaffSPTxt4" runat="server" TextMode="Password"></asp:TextBox>
<asp:RequiredFieldValidator ID="StaffSPReq3" runat="server" ErrorMessage="Password Hint is BLANK" ForeColor="Red" ControlToValidate="StaffSPTxt4"></asp:RequiredFieldValidator><br /><br />
<asp:Button ID="Button3" runat="server" Text="Sign Up" />
<asp:Button ID="Button4" runat="server" Text="Cancel" />
</asp:Panel>
<asp:Panel ID="StaffFP" CssClass="modalPopup" style="display: none" runat="server">
<asp:Label ID="Label23" runat="server" Text="Staff Forgot Password" Font-Size="XX-Large"></asp:Label><br /><br />
<asp:Label ID="Label24" runat="server" Text="Enter Username : "></asp:Label>
<asp:TextBox ID="StaffFPTxt1" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="StaffFPReq1" runat="server" ErrorMessage="Username is BLANK" ForeColor="Red" ControlToValidate="StaffFPTxt1"></asp:RequiredFieldValidator><br /><br />
<asp:Label ID="Label25" runat="server" Text="Enter Password Hint : "></asp:Label>
<asp:TextBox ID="StaffFPTxt2" runat="server" TextMode="Password"></asp:TextBox>
<asp:RequiredFieldValidator ID="StaffFPReq2" runat="server" ErrorMessage="Hint is BLANK" ForeColor="Red" ControlToValidate="StaffFPTxt2"></asp:RequiredFieldValidator><br /><br />
<asp:Button ID="Button5" runat="server" Text="GetPassword" />
<asp:Button ID="Button6" runat="server" Text="Cancel" />
</asp:Panel>
<asp:Panel ID="AdminSP" CssClass="modalPopup" style="display: none" runat="server">
<asp:Label ID="Label26" runat="server" Text="Coordinator Sign Up" Font-Size="XX-Large"></asp:Label><br /><br />
<asp:Label ID="Label27" runat="server" Text="Select Department : "></asp:Label>
<asp:DropDownList ID="AdminSPDrp1" runat="server" ></asp:DropDownList>
<asp:RequiredFieldValidator ID="AdminSPReq1" runat="server" ErrorMessage="Department is BLANK" ForeColor="Red" ControlToValidate="AdminSPDrp1"></asp:RequiredFieldValidator><br /><br />
<asp:Label ID="Label28" runat="server" Text="Select Branch : "></asp:Label>
<asp:DropDownList ID="AdminSPDrp2" runat="server" ></asp:DropDownList>
<asp:RequiredFieldValidator ID="AdminSPReq2" runat="server" ErrorMessage="Branch is BLANK" ForeColor="Red" ControlToValidate="AdminSPDrp2"></asp:RequiredFieldValidator><br /><br />
<asp:Label ID="Label29" runat="server" Text="Enter Username : "></asp:Label>
<asp:TextBox ID="AdminSPTxt1" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="AdminSPReq3" runat="server" ErrorMessage="Username is BLANK" ForeColor="Red" ControlToValidate="AdminSPTxt1"></asp:RequiredFieldValidator><br /><br />
<asp:Label ID="Label30" runat="server" Text="Enter Password : "></asp:Label>
<asp:TextBox ID="AdminSPTxt2" runat="server" TextMode="Password"></asp:TextBox>
<asp:RequiredFieldValidator ID="AdminSPReq4" runat="server" ErrorMessage="Password is BLANK" ForeColor="Red" ControlToValidate="AdminSPTxt2"></asp:RequiredFieldValidator><br /><br />
<asp:Label ID="Label31" runat="server" Text="Retype Password : "></asp:Label>
<asp:TextBox ID="AdminSPTxt3" runat="server" TextMode="Password"></asp:TextBox>
<asp:CompareValidator ID="AdminSPCom1" runat="server" ControlToValidate = "AdminSPTxt3" ControlToCompare = "AdminSPTxt2" ErrorMessage="Password Mismatch" ForeColor="Red"></asp:CompareValidator><br /><br />
<asp:Label ID="Label32" runat="server" Text="Enter Password Hint : "></asp:Label>
<asp:TextBox ID="AdminSPTxt4" runat="server" TextMode="Password"></asp:TextBox>
<asp:RequiredFieldValidator ID="AdminSPReq5" runat="server" ErrorMessage="Hint is BLANK" ForeColor="Red" ControlToValidate="AdminSPTxt4"></asp:RequiredFieldValidator><br /><br />
<asp:Button ID="Button7" runat="server" Text="Sign Up" />
<asp:Button ID="Button8" runat="server" Text="Cancel" />
</asp:Panel>
<asp:Panel ID="AdminFP" CssClass="modalPopup" style="display: none" runat="server">
<asp:Label ID="Label33" runat="server" Text="Coordinator Forgot Password" Font-Size="XX-Large"></asp:Label><br /><br />
<asp:Label ID="Label34" runat="server" Text="Select Department : "></asp:Label>
<asp:DropDownList ID="AdminFPDrp1" runat="server" ></asp:DropDownList>
<asp:RequiredFieldValidator ID="AdminFPReq1" runat="server" ErrorMessage="Department is BLANK" ForeColor="Red" ControlToValidate="AdminFPDrp1"></asp:RequiredFieldValidator><br /><br />
<asp:Label ID="Label35" runat="server" Text="Select Branch : "></asp:Label>
<asp:DropDownList ID="AdminFPDrp2" runat="server" ></asp:DropDownList>
<asp:RequiredFieldValidator ID="AdminFPReq2" runat="server" ErrorMessage="Branch is BLANK" ForeColor="Red" ControlToValidate="AdminFPDrp2"></asp:RequiredFieldValidator><br /><br />
<asp:Label ID="Label36" runat="server" Text="Enter Username : "></asp:Label>
<asp:TextBox ID="AdminFPTxt1" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="AdminFPReq3" runat="server" ErrorMessage="Username is BLANK" ForeColor="Red" ControlToValidate="AdminFPTxt1"></asp:RequiredFieldValidator><br /><br />
<asp:Label ID="Label37" runat="server" Text="Enter Password Hint : "></asp:Label>
<asp:TextBox ID="AdminFPTxt2" runat="server" TextMode="Password"></asp:TextBox>
<asp:RequiredFieldValidator ID="AdminFPReq4" runat="server" ErrorMessage="Hint is BLANK" ForeColor="Red" ControlToValidate="AdminFPTxt2"></asp:RequiredFieldValidator><br /><br />
<asp:Button ID="Button9" runat="server" Text="Sign Up" />
<asp:Button ID="Button10" runat="server" Text="Cancel" />
</asp:Panel>
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<asp:ModalPopupExtender ID="ModalPopupExtender1" BackgroundCssClass="modalBackground" PopupControlID = "StaffSP" CancelControlID = "Button4" TargetControlID = "StaffSignUp" runat="server"></asp:ModalPopupExtender>
<asp:ModalPopupExtender ID="ModalPopupExtender2" BackgroundCssClass="modalBackground" PopupControlID = "StaffFP" CancelControlID = "Button6" TargetControlID = "StaffForPwd" runat="server"></asp:ModalPopupExtender>
<asp:ModalPopupExtender ID="ModalPopupExtender3" BackgroundCssClass="modalBackground" PopupControlID = "AdminSP" CancelControlID = "Button8" TargetControlID = "AdminSignUp" runat="server"></asp:ModalPopupExtender>
<asp:ModalPopupExtender ID="ModalPopupExtender4" BackgroundCssClass="modalBackground" PopupControlID = "AdminFP" CancelControlID = "Button10" TargetControlID = "AdminForPwd" runat="server"></asp:ModalPopupExtender>
</div>
</form>
</body>
</html>
This is code behind page :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class MasterFinal : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void LinkAdmin_Click(object sender, EventArgs e)
{
AdminLogin.Visible = true;
StaffLogin.Visible = false;
}
protected void LinkStaff_Click(object sender, EventArgs e)
{
AdminLogin.Visible = false;
StaffLogin.Visible = true;
}
}
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...