obout gridview - using edit template - asp.net

Hello guys i am working with obout gridview and i am trying to make an edit template for my grid, i looked up on their site but i still cant solve a problem with updating the needed rows .
When i pick a row to edit i got a template with different look that has 4 textboxes that should be connected to 4 of the cells on the choosen row of the grid. The problem those textboxes aint getting updated and even when i as a user fill them up and click update i can see on debugger that they are strings of "".
This is the grid altough maybe there is something else that needs to be done to solve this? i am kinda new to this, Thanks in advance!
<cc1:Grid ID="budgetGrid" runat="server"
EnableTypeValidation="false" CallbackMode="true" Serialize="true" AutoPostBackOnSelect="false"
AllowGrouping="True" FolderStyle="~/styles/premiere_blue"
OnUpdateCommand="UpdateRecord"
DataSourceID="budgetSql" GroupBy="year,departmentName" ShowColumnsFooter="True"
ShowGroupFooter="True" ShowMultiPageGroupsInfo="False"
AllowAddingRecords="False" PageSize="-1" AllowPageSizeSelection="False"
AllowPaging="False">
<GroupingSettings AllowChanges="False" />
<Columns>
<cc1:Column ID="Column1" runat="server" AllowEdit="true" HeaderText="Edit"
width="100" FooterStyle-Font-Size="Smaller">
<FooterStyle Font-Size="Smaller" />
</cc1:Column>
<cc1:Column ID="column0" HeaderText="ID" readonly="true" Visible="false" runat="server" DataField="id" FooterStyle-Font-Size="Smaller">
<FooterStyle Font-Size="Smaller" />
</cc1:Column>
<cc1:Column ID="Column2" HeaderText="Department" readonly="true" Visible="false" runat="server" DataField="departmentName" FooterStyle-Font-Size="Smaller">
<FooterStyle Font-Size="Smaller" />
</cc1:Column>
<cc1:Column ID="Column3" HeaderText="Sub Dep" readonly="true" runat="server" DataField="subDepName" Width="100" FooterStyle-Font-Size="Smaller">
<FooterStyle Font-Size="Smaller" />
</cc1:Column>
<cc1:Column ID="Column11" HeaderText="Q1Bud" readonly="false" runat="server" DataField="Q1B" Width="100" FooterStyle-Font-Size="Smaller">
<FooterStyle Font-Size="Smaller" />
<TemplateSettings RowEditTemplateControlId="budgetQ1" RowEditTemplateControlPropertyName="value" />
</cc1:Column>
<cc1:Column ID="Column8" HeaderText="Q2Bud" readonly="false" runat="server" DataField="Q2B" Width="100" FooterStyle-Font-Size="Smaller">
<FooterStyle Font-Size="Smaller" />
<TemplateSettings RowEditTemplateControlId="budgetQ2" RowEditTemplateControlPropertyName="value" />
</cc1:Column>
<cc1:Column ID="Column9" HeaderText="Q3Bud" readonly="false" runat="server" DataField="Q3B" Width="100" FooterStyle-Font-Size="Smaller">
<FooterStyle Font-Size="Smaller" />
<TemplateSettings RowEditTemplateControlId="budgetQ3" RowEditTemplateControlPropertyName="value" />
</cc1:Column>
<cc1:Column ID="Column10" HeaderText="Q4Bud" readonly="false" runat="server" DataField="Q4B" Width="100" FooterStyle-Font-Size="Smaller">
<FooterStyle Font-Size="Smaller" />
<TemplateSettings RowEditTemplateControlId="budgetQ4" RowEditTemplateControlPropertyName="value" />
</cc1:Column>
<cc1:Column ID="Column4" HeaderText="Q1App" readonly="true" runat="server" DataField="Q1A" Width="100" FooterStyle-Font-Size="Smaller">
<FooterStyle Font-Size="Smaller" />
</cc1:Column>
<cc1:Column ID="Column5" HeaderText="Q2App" readonly="true" runat="server" DataField="Q2A" Width="100" FooterStyle-Font-Size="Smaller">
<FooterStyle Font-Size="Smaller" />
</cc1:Column>
<cc1:Column ID="Column6" HeaderText="Q3App" readonly="true" runat="server" DataField="Q3A" Width="100" FooterStyle-Font-Size="Smaller">
<FooterStyle Font-Size="Smaller" />
</cc1:Column>
<cc1:Column ID="Column7" HeaderText="Q4App" readonly="true" runat="server" DataField="Q4A" Width="100" FooterStyle-Font-Size="Smaller">
<FooterStyle Font-Size="Smaller" />
</cc1:Column>
<cc1:Column ID="Column13" HeaderText="Year" readonly="true" Visible="false" runat="server" DataField="year" FooterStyle-Font-Size="Smaller" Width="60">
<FooterStyle Font-Size="Smaller" />
</cc1:Column>
</Columns>
<TemplateSettings RowEditTemplateId="tplRowEdit" />
<Templates>
<cc1:GridTemplate runat="server" ID="tplRowEdit">
<Template>
<table class="rowEditTable">
<tr>
<td valign="top">
<fieldset style="width: 275px; height: 175px;">
<legend>Budget Amount</legend>
<table class="rowEditTable">
<tr>
<br />
<td>Quarter 1:</td>
<td> <cc1:OboutTextBox runat="server" ID="budgetQ1" Width="150"></cc1:OboutTextBox>
</td>
</tr>
<tr>
<td>Quarter 2:</td>
<td>
<cc1:OboutTextBox runat="server" ID="budgetQ2" Width="150"></cc1:OboutTextBox>
</td>
</tr>
<tr>
<td>Quarter 3:</td>
<td>
<cc1:OboutTextBox runat="server" ID="budgetQ3" Width="150"></cc1:OboutTextBox>
</td>
</tr>
<tr>
<td>Quarter 4:</td>
<td>
<cc1:OboutTextBox runat="server" ID="budgetQ4" Width="150"></cc1:OboutTextBox>
</td>
</tr>
<tr>
<td colspan="2">
<br />
</td>
</tr>
</table>
</fieldset>
</td>
</tr>
<tr>
<td colspan="3" align="center">
<input type="button" value="Save" onclick="budgetGrid.save()" />
<input type="button" value="Cancel" onclick="budgetGrid.cancel()" />
</td>
</tr>
</table>
</Template>
</cc1:GridTemplate>
</Templates>
</cc1:Grid>

I found a solution some time ago , i created the gridview in the page load event from zero and by doing so i got full control on all the changes editing etc, which seem to cause many problems while trying to do so with existing gridview on the html view.

Related

GridView is Shacking when i clicked my add Button

When i Click add button My Grid is shacking.
the Button Id is="AddNewUnit"
If i click Add or Edit button my grid is shrinking and suddenly comeback to normal size for 1st time only.
If the page is refresh again same problem is doing.
I dont know how to solve the problem.
If any body know the problem. Let me know.
<dx:ASPxCallbackPanel runat="server" ID="CallbackPanel" ClientInstanceName="CallbackPanel" >
<PanelCollection>
<dx:PanelContent ID="PanelContent3" runat="server">
<dx:ASPxButton ID="AddNewUnit" ClientInstanceName="AddNewUnit" runat="server" Text="Add New" OnInit="AddNewUnit_Init" Image-Url="~/App_Themes/Images/add.png"
AutoPostBack="false">
<ClientSideEvents Click="function(s, e) {Grdview.AddNewRow(); }" />
<Image Url="~/App_Themes/Images/add.png"></Image>
</dx:ASPxButton>
<dx:ASPxLabel ID="lblindex" ClientInstanceName="lblindex" runat="server" ClientVisible="false"></dx:ASPxLabel>
<dx:ASPxGridView ID="Grdview" ClientInstanceName="Grdview" runat="server" OnRowDeleting="Grdview_RowDeleting"
KeyFieldName="Id" AutoGenerateColumns="False" Width="100%" OnRowInserting="Grdview_RowInserting"
OnRowUpdating="Grdview_RowUpdating" OnCellEditorInitialize="Grdview_CellEditorInitialize">
<ClientSideEvents CustomButtonClick="custombuttonclicks" />
<Columns>
<dx:GridViewCommandColumn VisibleIndex="0" Caption="Edit" Width="6%" Name="EditButton" ShowEditButton="true">
<HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" Font-Bold="True"></HeaderStyle>
<CellStyle HorizontalAlign="Center" VerticalAlign="Middle"></CellStyle>
</dx:GridViewCommandColumn>
<dx:GridViewCommandColumn ShowNewButton="true" Name="Delete" ShowEditButton="false" VisibleIndex="1" ButtonType="Image"
Width="6%" Caption="Delete">
<HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" Font-Bold="True"></HeaderStyle>
<CellStyle HorizontalAlign="Center" VerticalAlign="Middle"></CellStyle>
<CustomButtons>
<dx:GridViewCommandColumnCustomButton ID="deluser">
<Image ToolTip="Delete" Url="App_Themes/Images/delete.png" Width="22px" Height="22px" />
</dx:GridViewCommandColumnCustomButton>
</CustomButtons>
<HeaderStyle Wrap="True" Font-Bold="True"></HeaderStyle>
</dx:GridViewCommandColumn>
<dx:GridViewDataTextColumn FieldName="Name" VisibleIndex="1" Width="14%" Settings-AutoFilterCondition="Contains"
Caption="Name">
<HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" Font-Bold="True"></HeaderStyle>
<CellStyle HorizontalAlign="Left" VerticalAlign="Middle"></CellStyle>
<PropertiesTextEdit Width="250px">
<ValidationSettings ErrorDisplayMode="Text" ErrorTextPosition="Bottom">
<RequiredField IsRequired="True" ErrorText="Please enter the Name"></RequiredField>
</ValidationSettings>
</PropertiesTextEdit>
<Settings AutoFilterCondition="Contains"></Settings>
<EditFormSettings VisibleIndex="0" Caption="Name" />
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn FieldName="Age" Caption="Age" VisibleIndex="2" Width="10%" PropertiesTextEdit-MaxLength="50"
HeaderStyle-Font-Bold="true" CellStyle-HorizontalAlign="Left" PropertiesTextEdit-ValidationSettings-RequiredField-ErrorText="Please enter the No. Of Beds"
Settings-AutoFilterCondition="Contains">
<HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" Font-Bold="True"></HeaderStyle>
<CellStyle HorizontalAlign="Right" VerticalAlign="Middle"></CellStyle>
<PropertiesTextEdit Width="250px" ValidationSettings-ErrorDisplayMode="Text">
<Style HorizontalAlign="Right">
</Style>
<ValidationSettings ErrorTextPosition="Bottom">
<RequiredField IsRequired="true" />
<RegularExpression ValidationExpression="^\d*\.?\d*$" ErrorText="Age accepts only numbers" />
</ValidationSettings>
</PropertiesTextEdit>
<EditFormSettings VisibleIndex="2" Caption="Age" />
</dx:GridViewDataTextColumn>
<dx:GridViewDataMemoColumn FieldName="Country" Width="35%" VisibleIndex="3" Caption="Country"
Settings-AutoFilterCondition="Contains">
<HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" Font-Bold="True"></HeaderStyle>
<CellStyle HorizontalAlign="Left" VerticalAlign="Middle"></CellStyle>
<PropertiesMemoEdit Height="50px" Width="250px">
<ValidationSettings ErrorDisplayMode="Text" ErrorTextPosition="Bottom">
<RequiredField IsRequired="True" ErrorText="Please enter the Country" />
</ValidationSettings>
</PropertiesMemoEdit>
<EditFormSettings VisibleIndex="3" Caption="Country" />
</dx:GridViewDataMemoColumn>
<dx:GridViewDataMemoColumn FieldName="State" Width="35%" VisibleIndex="4" Caption="State"
Settings-AutoFilterCondition="Contains">
<HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" Font-Bold="True"></HeaderStyle>
<CellStyle HorizontalAlign="Left" VerticalAlign="Middle"></CellStyle>
<PropertiesMemoEdit Height="50px" Width="250px">
<ValidationSettings ErrorDisplayMode="Text" ErrorTextPosition="Bottom">
<RequiredField IsRequired="True" ErrorText="Please enter the State" />
</ValidationSettings>
</PropertiesMemoEdit>
<EditFormSettings VisibleIndex="4" Caption="State" />
</dx:GridViewDataMemoColumn>
</Columns>
<SettingsCommandButton ApplyFilterButton-ButtonType="Button" ApplyFilterButton-Styles-FocusRectStyle-VerticalAlign="Middle">
<EditButton ButtonType="Image" Image-Height="24px" Image-Width="24px" Image-Url="App_Themes/Images/blueedit.png" Image-ToolTip="Edit">
<Image ToolTip="Edit" Height="24px" Width="24px" Url="App_Themes/Images/blueedit.png"></Image>
</EditButton>
<CancelButton ButtonType="Button" Styles-Style-VerticalAlign="Middle" Styles-Style-HorizontalAlign="Center" Image-ToolTip="Close Edit Form Without Saving Changes" Image-Width="60px">
<Image ToolTip="Close Edit Form Without Saving Changes" Width="60px"></Image>
<Styles>
<Style HorizontalAlign="Center" VerticalAlign="Middle"></Style>
</Styles>
</CancelButton>
<ShowAdaptiveDetailButton ButtonType="Image"></ShowAdaptiveDetailButton>
<HideAdaptiveDetailButton ButtonType="Image"></HideAdaptiveDetailButton>
<ApplyFilterButton ButtonType="Button" RenderMode="Button">
<Styles>
<FocusRectStyle VerticalAlign="Middle"></FocusRectStyle>
</Styles>
</ApplyFilterButton>
<UpdateButton ButtonType="Button" Styles-Style-VerticalAlign="Middle" Styles-Style-HorizontalAlign="Center" Image-ToolTip="Saving Changes." Image-Width="60px">
<Image ToolTip="Saving Changes." Width="60px"></Image>
<Styles>
<Style HorizontalAlign="Center" VerticalAlign="Middle"></Style>
</Styles>
</UpdateButton>
</SettingsCommandButton>
<SettingsEditing EditFormColumnCount="2" Mode="PopupEditForm">
</SettingsEditing>
<SettingsPager Mode="ShowPager" AlwaysShowPager="true" PageSize="10" Position="Bottom">
<PageSizeItemSettings Visible="true" Caption="Units to display" Items="5, 10, 25, 50" />
</SettingsPager>
<Settings ShowFilterRow="true" ShowFilterRowMenu="true" VerticalScrollBarMode="Visible" VerticalScrollableHeight="432" />
<SettingsPopup>
<EditForm Width="760px" HorizontalAlign="WindowCenter" VerticalAlign="WindowCenter" Modal="true" />
</SettingsPopup>
<Settings ShowTitlePanel="false" />
<SettingsText Title="Add New" PopupEditFormCaption="Edit" />
</dx:ASPxGridView>
</dx:PanelContent>
</PanelCollection>
</dx:ASPxCallbackPanel>
<dx:ASPxPopupControl ID="PopupforCustDeletePopupSubmitConfirmation" runat="server" ShowPageScrollbarWhenModal="true" PopupHorizontalAlign="WindowCenter" PopupVerticalAlign="WindowCenter" ClientInstanceName="PopupforCustDeletePopupSubmitConfirmation" AllowDragging="false" AllowResize="false" HeaderText="Alert"
EnableHotTrack="False" HeaderStyle-Font-Bold="true" CloseAction="CloseButton" Modal="True" HeaderStyle-HorizontalAlign="Left">
<ContentCollection>
<dx:PopupControlContentControl ID="PopupControlContentControl1" runat="server">
<dx:ASPxPanel ID="ASPxPanel1" runat="server" DefaultButton="btOK">
<PanelCollection>
<dx:PanelContent ID="PanelContent2" runat="server">
<table style="width: 400px">
<tr>
<td align="center">
<dx:ASPxLabel ID="lblCustDeletePopupConfirmationMsg" ViewStateMode="Disabled" runat="server" Text="Are you sure you want to delete the Unit?">
</dx:ASPxLabel>
</td>
</tr>
</table>
</dx:PanelContent>
</PanelCollection>
</dx:ASPxPanel>
<br />
<br />
<table style="width: 100px; margin: auto;">
<tr>
<td align="center" style="width: 50px">
<dx:ASPxButton ID="btnCustDeletePopupYes" runat="server" Text="Yes" Width="55px" AutoPostBack="false" ToolTip="Yes">
<ClientSideEvents Click="CustDeletePopupYes_Click" />
</dx:ASPxButton>
</td>
<td align="center" style="width: 49px; padding-left: 5px;">
<dx:ASPxButton ID="btnCustDeletePopupNo" runat="server" Text="No" AutoPostBack="false" Width="55px" ToolTip="No">
<ClientSideEvents Click="CustDeletePopupNo_Click" />
</dx:ASPxButton>
</td>
</tr>
</table>
</dx:PopupControlContentControl>
</ContentCollection>
<HeaderStyle>
<Paddings PaddingRight="6px"></Paddings>
</HeaderStyle>
<SizeGripImage Height="16px" Width="16px">
</SizeGripImage>
</dx:ASPxPopupControl>
My Screenshot attached Here
<dx:ASPxFormLayout ID="ASPxFormLayout1" runat="server"></dx:ASPxFormLayout>
<dx:ASPxPopupControl ID="ASPxPopupControl1" runat="server"></dx:ASPxPopupControl>
before aspxcallbackpanel paste it never shake.

Dropdown List issue in ASP Panel control

I am using asp Panel control in which I have a dropdown list for different Timezones to select.
However, When I select any timezone It disappears when I open the pop up next time.
Can you please suggest or provide some pointers ?
<asp:PlaceHolder ID="DisplayMode" runat="server">
<div id="ListBranch" style="text-align: left">
<asp:Button ID="AddBranch" runat="server" Text="Add Branch" OnClick="AddBranch_Click" />
<act:ModalPopupExtender ID="ModalPopupExtenderBranch" runat="server" TargetControlID="AddBranch" PopupControlID="pnlAddBranch"
CancelControlID="btnCancel" BackgroundCssClass="modalBackground">
</act:ModalPopupExtender>
<act:ToolkitScriptManager ID="smBranch" runat="server">
</act:ToolkitScriptManager>
<div>
<br />
<asp:GridView runat="server" ID="gvBranchList" DataKeyNames="BranchID" AutoGenerateColumns="false" Font-Size="Small">
<RowStyle BackColor="#EFF3FB" />
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<HeaderStyle BackColor="#336699" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="White" />
<Columns>
<asp:BoundField DataField="Branch Name" HeaderText="Branch Name" />
<asp:BoundField DataField="Timezone" HeaderText="Timezone" />
<asp:TemplateField HeaderText="Edit">
<ItemTemplate>
<asp:Button ID="Edit" runat="server" Text="Edit" OnClick="Edit_Click" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<br />
<asp:Label ID="lblresult" runat="server" />
<asp:Button ID="btnShowPopup" runat="server" Style="display: none" />
<asp:Button ID="UpdateBranch" CommandName="Update" runat="server" Text="Ok" OnClick="Ok_Click" Style="display: none" />
<asp:Panel ID="pnlAddBranch" runat="server" BackColor="White" Height="80%" Width="100%" Font-Size="Small" Style="top: 40px !important;">
<table style="border: solid 2px #336699; width: 100%; height: 100%; font-size: small;" cellpadding="0" cellspacing="0">
<tr style="background-color: #336699">
<td colspan="2" style="height: 5%; color: White; font-weight: bold; font-size: larger" align="center">Branch Details</td>
</tr>
<tr>
<td align="left">Branch Name: </td>
<td>
<asp:TextBox ID="BranchName" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td align="left">Timezone: </td>
<td>
<asp:DropDownList ID="ddlTimezones" AutoPostBack="false" OnSelectedIndexChanged="ddlTimezones_SelectedIndexChanged" runat="server" />
</td>
</tr>
<tr>
<td align="left">Assigned Holidays: </td>
<td>
<asp:CheckBoxList ID="chkAssignedHolidays" runat="server" RepeatColumns="3" Font-Size="Small" />
</td>
</tr>
<tr>
<td></td>
<td>
<asp:Button ID="Ok" CommandName="Add" runat="server" Text="Ok" OnClick="Ok_Click" />
<asp:Button ID="Cancel" Commandname="Cancel" runat="server" Text="Cancel" OnClick="Cancel_Click" />
</td>
</tr>
<tr>
<td colspan="2">
<asp:Label ID="lblBranchID" runat="server" Style="display: none"></asp:Label>
</td>
</tr>
</table>
</asp:Panel>
</div>
</div>
</asp:PlaceHolder>

Exporting Excel is giving error on button click

I am implementing the functionality that on button click the data saved in the gridview should get exported on the button click, I implemented the functionality from here.
But I am getting error as Control 'mainContent_grdTeacherProfile' of type 'GridView' must be placed inside a form tag with runat=server at line
grdTeacherProfile.RenderControl(hw);
Please see the asps code of the gridview:-
<asp:GridView ID="grdTeacherProfile"
runat="server"
Width="100%"
border="1" Style="border: 1px solid #E5E5E5;"
CellPadding="3" FooterStyle-BackColor="#e3e3e3"
AutoGenerateColumns="false"
AllowPaging="true"
CssClass="hoverTable"
DataKeyNames="Id"
PageSize="4"
ShowFooter="false"
OnPreRender="PreRenderGrid"
HeaderStyle-CssClass="k-grid td"
OnDataBound="grdTeacherProfile_DataBound"
OnPageIndexChanging="grdTeacherProfile_PageIndexChanging"
OnRowDeleting="grdTeacherProfile_RowDeleting"
OnRowCommand="grdTeacherProfile_RowCommand"
EnableSortingAndPagingCallbacks="false"
EmptyDataText="No records found">
<AlternatingRowStyle CssClass="k-alt" />
<Columns>
<asp:TemplateField HeaderText="Select" ItemStyle-Width="5" >
<ItemTemplate>
<asp:CheckBox ID="chkDelete" runat="server" onClick="Check_Click(this)" />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="first_name" HeaderText="First Name" ItemStyle-Width="30" />
<asp:BoundField DataField="last_name" HeaderText="Last Name" ItemStyle-Width="30" />
<asp:BoundField DataField="dob" HeaderText="Date of Birth" ItemStyle-Width="20" ApplyFormatInEditMode="true" DataFormatString="{0:d}" />
<asp:BoundField DataField="gender" HeaderText="Gender" ItemStyle-Width="20" />
<asp:BoundField DataField="designation" HeaderText="Designation" ItemStyle-Width="20" />
<asp:BoundField DataField="joining_date" HeaderText="Joining Date" ItemStyle-Width="20" ApplyFormatInEditMode="true" DataFormatString="{0:d}" />
<asp:BoundField DataField="leaving_date" HeaderText="Leaving Date" ItemStyle-Width="20" ApplyFormatInEditMode="true" DataFormatString="{0:d}" />
<asp:BoundField DataField="active" HeaderText="Active" ItemStyle-Width="25" />
<asp:TemplateField HeaderText="Action" HeaderStyle-Width="5%">
<ItemTemplate>
<asp:ImageButton ID="btnEdit" AlternateText="Edit" ImageUrl="~/images/edit.png" runat="server" Width="15" Height="15" CommandName="eEdit" CommandArgument='<%# Eval("Id") %>' CausesValidation="false" />
<asp:ImageButton ID="btnDelete" AlternateText="Delete" ImageUrl="~/images/delete.png" runat="server" Width="15" Height="15" CommandName="Delete" CommandArgument='<%# Eval("Id") %>' CausesValidation="false" OnClientClick="return confirm('Are you sure you want to delete this record?')" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
<PagerStyle ForeColor="#e3e3e3"
BackColor="#e3e3e3" CssClass="grid-pagi" />
<PagerTemplate>
<table runat="server" id="testTable1" style="width: 100%" class="hoverTable_tbl">
<tr>
<td class="col-md-4 pull-left">
<asp:Label ID="MessageLabel"
Text="Select a page:"
runat="server" />
<asp:LinkButton ID="FirstLB" runat="server" CommandName="Page" CommandArgument="First" ToolTip="First" CssClass="btn-pager btn-default"><<</asp:LinkButton>
<asp:LinkButton ID="PrevLB" runat="server" CommandName="Page" CommandArgument="Prev" ToolTip="Previous" CssClass="btn-pager btn-default"><</asp:LinkButton>
<asp:DropDownList runat="server" ID="PageDropDownList" AutoPostBack="true" EnableViewState="true" OnSelectedIndexChanged="PageDropDownList_SelectedIndexChanged" CssClass="selectpicker form-control-drp"></asp:DropDownList>
<asp:LinkButton ID="NextLB" runat="server" CommandName="Page" CommandArgument="Next" ToolTip="Next" CssClass="btn-pager btn-default">></asp:LinkButton>
<asp:LinkButton ID="LastLB" runat="server" CommandName="Page" CommandArgument="Last" ToolTip="Last" CssClass="btn-pager btn-default">>></asp:LinkButton>
</td>
<td class="col-md-3">
<div>
<div class="pull-left"><asp:Label ID="PageSizeLabel" CssClass="page-size" runat="server" Text="Select Page Size: "></asp:Label>
<asp:DropDownList ID="ddlPageSize" runat="server" OnSelectedIndexChanged="ddlPageSize_SelectedIndexChanged" AutoPostBack="true" CssClass="selectpicker form-control-drp">
<%-- <asp:ListItem Value="0" Text="0" />--%>
<asp:ListItem Value="1" Text="1" />
<asp:ListItem Value="2" Text="2" />
<asp:ListItem Value="3" Text="3" />
</asp:DropDownList>
</div>
<div>
<asp:Label ID="CurrentPageLabel" CssClass="view" runat="server" />
</div>
</div>
</td>
</tr>
</table>
</PagerTemplate>
<RowStyle />
</asp:GridView>
Exporting GridView to Excel is easier using a 3rd party like iTextSharp.
If you want to know how I make it work, you can check this sample code:
http://dotnetfrommanila.blogspot.com/2013/04/convert-gridview-to-excel-in-c.html
I hope it could help you.
I got it done on my own,
actually I forgot to add the code below and EnableEventValidation="false".
The code was:-
public override void VerifyRenderingInServerForm(Control control)
{
/* Verifies that the control is rendered */
}
and it worked.!!

Page Div align not showing correctly

I have a weird situation and believe that it must be easy for people to help me out on this specific issue. I have two divs on a child page that i want to show next to each other. I mean, One on left and one on right. After that, on the bottom of the screen I want to display a table that covers 100% width.
I have used float left on one div and float right on another div. Then i show the heading of the table on the bottom, then the table displays.
My problem is that the despite all my efforts the heading is displaying in between these two divs. Here is my code.
<div id="ContainerDiv" runat="server" style="width: 930px">
<div id="DivticketDetails" runat="server" visible="false"
style="float: left; width: 400px;">
<asp:Panel ID="PanelTicketDetails" runat="server" BackColor="#8B9FBE">
<h3 style="color: #FFFFFF; font-weight: bold; text-decoration: underline;">
Bowzer Details</h3>
<table border="1" cellpadding="0" cellspacing="0" class="myTable">
<tr>
<td bgcolor="#507CD1">
<asp:Label ID="Label6" runat="server" Text="Field / Customer Name" Font-Bold="True"
Font-Size="XX-Small" BorderColor="#507CD1" ForeColor="White"></asp:Label>
</td>
<td>
<asp:Label ID="lbl_FieldName" runat="server" Text="lbl_FieldName" CssClass="myLabel"></asp:Label>
</td>
</tr>
<tr>
<td bgcolor="#507CD1">
<asp:Label ID="Label3" runat="server" Text="Challan Generated On" Font-Bold="True"
Font-Size="XX-Small" BorderColor="#507CD1" ForeColor="White"></asp:Label>
</td>
<td>
<asp:Label ID="lbl_firstEntryDate" runat="server" Text="lbl_firstEntryDate" Font-Size="Small"
CssClass="myLabel"></asp:Label>
</td>
</tr>
<tr>
<td bgcolor="#507CD1">
<asp:Label ID="Label4" runat="server" Text="Product Name" Font-Bold="True" Font-Size="XX-Small"
BorderColor="#507CD1" ForeColor="White"></asp:Label>
</td>
<td>
<asp:Label ID="lbl_ProductName" runat="server" Text="lbl_ProductName" Font-Size="Small"
CssClass="myLabel"></asp:Label>
</td>
</tr>
<tr>
<td bgcolor="#507CD1">
<asp:Label ID="Label2" runat="server" Text="Bowzer No" Font-Bold="True" Font-Size="XX-Small"
BorderColor="#507CD1" ForeColor="White"></asp:Label>
</td>
<td>
<asp:Label ID="lbl_bowzerNo" runat="server" Text="lbl_bowzerNo" Font-Size="Small"
CssClass="myLabel"></asp:Label>
</td>
</tr>
<tr>
<td bgcolor="#507CD1">
<asp:Label ID="Label28" runat="server" Text="Quantity" Font-Bold="True" Font-Size="XX-Small"
BorderColor="#507CD1" ForeColor="White"></asp:Label>
</td>
<td>
<asp:Label ID="lbl_BowQuantity" runat="server" Text="lbl_BowQuantity" Font-Size="Small"
CssClass="myLabel"></asp:Label>
</td>
</tr>
</table>
</asp:Panel>
</div>
<div id="Div2" runat="server" style="float: right; width: 429px;">
<asp:Panel ID="PanelBowzerHistory" runat="server" BackColor="#8B9FBE" Visible="False">
<h3 style="font-weight: bold; text-decoration: underline; color: #FFFFFF">
Bowzer History
</h3>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" CellPadding="4"
DataKeyNames="challan_id" DataSourceID="DSBowzerHistory" Font-Size="Smaller"
ForeColor="#333333" GridLines="None" AllowPaging="True" PageSize="4">
<AlternatingRowStyle BackColor="White" />
<Columns>
<asp:BoundField DataField="FirstWeight" HeaderText="FirstWeight" SortExpression="FirstWeight" />
<asp:BoundField DataField="Firstentry_date" HeaderText="Firstentry_date" SortExpression="Firstentry_date" />
<asp:BoundField DataField="SecondWeight" HeaderText="SecondWeight" SortExpression="SecondWeight" />
<asp:BoundField DataField="netWeight" HeaderText="netWeight" SortExpression="netWeight" />
<asp:BoundField DataField="SecondEntry_Date" HeaderText="SecondEntry_Date" SortExpression="SecondEntry_Date" />
<asp:BoundField DataField="challan_id" HeaderText="challan_id" InsertVisible="False"
ReadOnly="True" SortExpression="challan_id" />
</Columns>
<EditRowStyle BackColor="#2461BF" />
<FooterStyle BackColor="#507CD1" ForeColor="White" Font-Bold="True" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#EFF3FB" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#F5F7FB" />
<SortedAscendingHeaderStyle BackColor="#6D95E1" />
<SortedDescendingCellStyle BackColor="#E9EBEF" />
<SortedDescendingHeaderStyle BackColor="#4870BE" />
</asp:GridView>
</asp:Panel>
</div>
</div>
<div id="tblDetailsDiv" runat="server" visible="False" title="Ticket Details" style="width: 930px;
background-color: #8B9FBE;">
<h3 style="font-size: medium; color: #FFFFFF; font-weight: bold; width: 930px; background-color: #00FF00;">
Enter Details Here</h3>
<table id="tblDetails" title="Enter Details" border="0" cellpadding="0" cellspacing="0"
class="myTable" frame="border">
<tr>
<td>
</td>
<td>
</table>
</div>
and here is how it is displayed.
Try to change the float of second div to left, and after those two div.
Like this:
And add a new div with a clear style after those two divs.
Hope it works.
here u go. i added the code above

how to use validation controls in modelpopupextender

I am using a ModalPopupExtender in a GridView. When the user clicks link button in the grid to update the row values, the modal popup opens. The user updates the values and click on the update button.
I have used validation controls in the modal popup, but the when the user click update button the form submits with out validating the controls.
I tried with ValidationGroup as it's mentioned in some forums but no luck. Can any one help how to fix this or any good examples.
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
</div><asp:Button ID="btnShowPopup" runat="server" Text="Button" style="display:none"/><div >
<asp:GridView ID="GridView2" runat="server" BackColor="White"
BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px" CellPadding="4"
AutoGenerateColumns="False" ForeColor="Black" Width="100%"
onrowcreated="GridView2_RowCreated" onrowdatabound="GridView2_RowDataBound">
<Columns>
<asp:BoundField DataField="ShortDescription" HeaderText="ShortDescription" ReadOnly="True" ><ItemStyle Width="32%" /></asp:BoundField>
<asp:BoundField DataField="Planned" HeaderText="Planned" ReadOnly="True" >
<ItemStyle Width="5%" HorizontalAlign="Right" /></asp:BoundField>
<asp:BoundField DataField="Actual" HeaderText="Actual" ReadOnly="True" >
<ItemStyle Width="5%" HorizontalAlign="Right" /></asp:BoundField>
<asp:BoundField DataField="Error" HeaderText="Error" ReadOnly="True" >
<ItemStyle Width="5%" HorizontalAlign="Right" /></asp:BoundField>
<asp:BoundField DataField="Volume" HeaderText="Vol" ReadOnly="True"
DataFormatString="{0:#%}" >
<ItemStyle Width="3%" HorizontalAlign="Right" /></asp:BoundField>
<asp:BoundField DataField="Mix" HeaderText="Mix" ReadOnly="True"
DataFormatString="{0:#%}" >
<ItemStyle Width="3%" HorizontalAlign="Right" /></asp:BoundField>
<asp:BoundField DataField="PMReason" HeaderText="Reason" ><ItemStyle Width="9%" /></asp:BoundField>
<asp:BoundField DataField="PMComment" HeaderText="Comment" ><ItemStyle Width="9%" /></asp:BoundField>
<asp:BoundField DataField="PMPlanned" HeaderText="Planned" >
<ItemStyle Width="5%" HorizontalAlign="Right" /></asp:BoundField>
<asp:BoundField DataField="PMActual" HeaderText="Actual" ReadOnly="True" >
<ItemStyle Width="5%" HorizontalAlign="Right" /></asp:BoundField>
<asp:BoundField DataField="PMError" HeaderText="Error" >
<ItemStyle Width="5%"
HorizontalAlign="Right" /></asp:BoundField>
<asp:BoundField DataField="PMVolume" HeaderText="Vol" ReadOnly="True"
DataFormatString="{0:#%}" >
<ItemStyle Width="3%" HorizontalAlign="Right" /></asp:BoundField>
<asp:BoundField DataField="PMMix" HeaderText="Mix" ReadOnly="True"
DataFormatString="{0:#%}" >
<ItemStyle Width="3%" HorizontalAlign="Right" /></asp:BoundField>
<asp:TemplateField>
<ItemTemplate>
<asp:ImageButton ID="btnSelect" runat="server" CausesValidation="false"
ImageUrl="~/Images/edit.png"
ImageAlign="AbsMiddle" Height="15px" Width="15px"
onclick="btnSelect_Click" />
</ItemTemplate>
<ItemStyle Width="3%" />
</asp:TemplateField>
<asp:BoundField DataField="ReportRowId" Visible="False" />
</Columns>
<FooterStyle BackColor="#CCCC99" ForeColor="Black" />
<PagerStyle BackColor="White" ForeColor="Black" HorizontalAlign="Right" />
<SelectedRowStyle BackColor="#CC3333" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#333333" Font-Bold="True" ForeColor="White" />
</asp:GridView>
</div>
<cc2:ModalPopupExtender ID="gv_ModalPopupExtender" runat="server"
TargetControlID="btnShowPopup"
PopupControlID="pnlModalPanel"
CancelControlID="btnCancel"
BackgroundCssClass="modalBackground"/>
<asp:Panel ID="pnlModalPanel" runat="server" Style="display: none;" BackColor="Red">
<table>
<tr>
<th colspan="2" align="center" style="color:White; font-size:larger"> POST MITIGATION </th>
</tr>
<tr>
<td>
<asp:Label ID="lblRowId" runat="server" Style="display: none;"></asp:Label> </td>
<td></td>
</tr>
<tr>
<td>
<asp:Label ID="lblDevice" runat="server"
ForeColor="White" Font-Bold="True">Device:</asp:Label> </td>
<td><asp:TextBox ID="txtDevice" runat="server" Width="150px" ReadOnly="true"></asp:TextBox></td>
</tr>
<tr>
<td>
<asp:Label ID="lblPlanned" runat="server"
ForeColor="White" Font-Bold="True">Planned:</asp:Label> </td>
<td><asp:TextBox ID="txtPlanned" runat="server" Width="150px" ReadOnly="true"></asp:TextBox></td>
</tr>
<tr>
<td>
<asp:Label ID="lblActual" runat="server"
ForeColor="White" Font-Bold="True">Actual:</asp:Label> </td>
<td><asp:TextBox ID="txtActual" runat="server" Width="150px"></asp:TextBox></td>
</tr>
<tr>
<td>
<asp:Label ID="lblError" runat="server"
ForeColor="White" Font-Bold="True">Error:</asp:Label> </td>
<td><asp:TextBox ID="txtError" runat="server" Width="150px" ReadOnly="true"></asp:TextBox></td>
</tr>
<tr>
<td>
<asp:Label ID="lblReason" runat="server"
ForeColor="White" Font-Bold="True">Reason:</asp:Label> </td>
<td>
<asp:DropDownList ID="ddlReason" runat="server" Width="150px" ValidationGroup="valReason">
<asp:ListItem>-- Select Reason --</asp:ListItem>
<asp:ListItem></asp:ListItem>
<asp:ListItem>Availability LT</asp:ListItem>
<asp:ListItem>Availability ST</asp:ListItem>
<asp:ListItem>Competitor Response</asp:ListItem>
<asp:ListItem>Credit</asp:ListItem>
<asp:ListItem>Plan Issue</asp:ListItem>
<asp:ListItem>Props Change</asp:ListItem>
<asp:ListItem>SCL Request</asp:ListItem>
<asp:ListItem>Launch Delay</asp:ListItem>
<asp:ListItem>Launch Forward</asp:ListItem>
<asp:ListItem>Phasing</asp:ListItem>
<asp:ListItem>Opportunity-Positive</asp:ListItem>
<asp:ListItem>Opportunity-Negative</asp:ListItem>
</asp:DropDownList>
<asp:RequiredFieldValidator ID="rfvReason" ValidationGroup="valReason" runat="server" Text="*" ErrorMessage="RequiredFieldValidator"
ControlToValidate="ddlReason" Display="Dynamic" ForeColor="White" InitialValue="-- Select Reason --"></asp:RequiredFieldValidator></td>
</tr>
<tr>
<td>
<asp:Label ID="lblComment" runat="server"
ForeColor="White" Font-Bold="True">Comment:</asp:Label> </td>
<td><asp:TextBox ID="txtComment" TextMode="MultiLine" Height="50px" runat="server" Width="150px"></asp:TextBox></td>
</tr>
<tr>
<td colspan="2" align="center">
<asp:Button ID="btnUpdate" runat="server" CausesValidation="true" ValidationGroup="valReason"
Text="Update Mitigation" onclick="btnUpdate_Click" />
<asp:Button ID="btnCancel" runat="server" Text="Cancel"/></td>
</tr>
</table>
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
It worked when I removed the update button from the panel and replaced it with the new button.
But I am not sure why it didn't work before and why its working now. Its all the same code. Looks very strange to me.

Resources