0% found this document useful (0 votes)
111 views

Dev Express ShowSelect ShowEdit Project

This document contains ASPX code for a real estate fixture type form. It includes code for registering DevExpress controls, setting up page content sections, and defining a grid view bound to a SQL data source to display and manage fixture type records. Checkboxes and client-side JavaScript are used to handle row selection in the grid. Buttons allow exporting the full or selected data to PDF or XLSX formats.

Uploaded by

Ivan Avellaneda
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
111 views

Dev Express ShowSelect ShowEdit Project

This document contains ASPX code for a real estate fixture type form. It includes code for registering DevExpress controls, setting up page content sections, and defining a grid view bound to a SQL data source to display and manage fixture type records. Checkboxes and client-side JavaScript are used to handle row selection in the grid. Buttons allow exporting the full or selected data to PDF or XLSX formats.

Uploaded by

Ivan Avellaneda
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

[ASPX]

<%@ Page Title="" Language="VB" MasterPageFile="~/Site.master" AutoEventWireup="false"


CodeFile="RealEstateFixtureType.aspx.vb" Inherits="CorporateForms_RealEstateFixtureType" %>

<%@ Register Assembly="DevExpress.Web.v13.2, Version=13.2.8.0, Culture=neutral,


PublicKeyToken=b88d1754d700e49a"
Namespace="DevExpress.Web.ASPxEditors" TagPrefix="dx" %>

<%@ Register Assembly="DevExpress.Web.v13.2, Version=13.2.8.0, Culture=neutral,


PublicKeyToken=b88d1754d700e49a"
Namespace="DevExpress.Web.ASPxGridView.Export" TagPrefix="dx" %>

<%@ Register Assembly="DevExpress.Web.v13.2, Version=13.2.8.0, Culture=neutral,


PublicKeyToken=b88d1754d700e49a"
Namespace="DevExpress.Web.ASPxGridView" TagPrefix="dx" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" Runat="Server">
<link type="text/css" href="../Styles/jquery-ui-1.8.1.pepper.css" rel="Stylesheet" />
<script type="text/jscript" src="../Scripts/jquery-1.4.2.pepper.min.js"></script>
<script type="text/jscript" src="../Scripts/jquery-ui-1.8.1.pepper.min.js"></script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" Runat="Server">
<script language="javascript" type="text/javascript">
var _selectNumber = 0;
var _all = false;
var _handle = true;

function OnAllCheckedChanged(s, e) {
if (s.GetChecked())
grid.SelectRows();
else
grid.UnselectRows();
}

function OnGridSelectionChanged(s, e) {
cbAll.SetChecked(s.GetSelectedRowCount() == s.cpVisibleRowCount);

if (e.isChangedOnServer == false) {
if (e.isAllRecordsOnPage && e.isSelected)
_selectNumber = s.GetVisibleRowsOnPage();
else if (e.isAllRecordsOnPage && !e.isSelected)
_selectNumber = 0;
else if (!e.isAllRecordsOnPage && e.isSelected)
_selectNumber++;
else if (!e.isAllRecordsOnPage && !e.isSelected)
_selectNumber--;

if (_handle) {
cbPage.SetChecked(_selectNumber == s.GetVisibleRowsOnPage());
_handle = false;
}
_handle = true;
}
else {
cbPage.SetChecked(cbAll.GetChecked());
}
}

function OnPageCheckedChanged(s, e) {
_handle = false;
if (s.GetChecked())
grid.SelectAllRowsOnPage();
else
grid.UnselectAllRowsOnPage();
}
function OnGridEndCallback(s, e) {
_selectNumber = s.cpSelectedRowsOnPage;
}
</script>
<h1>
Real Estate - Fixture Type Form
</h1>
<h3>
<table>
<tr>
<td>1.&nbsp;&nbsp;All Fixture Types appear in the table below by default.</td>
</tr>
<tr>
<td>2.&nbsp;&nbsp;Filter, Group By, Export Selected Records functionality available from the
GridView below.</td>
</tr>
<tr>
<td>Your Computer's IP Address is: <asp:Label ID="IPAddress" runat="server" Visible="true"
/></td>
</tr>
</table>
</h3>
<asp:Label ID="UserNameMsg" runat="server" Visible="false" />
<asp:ValidationSummary ID="ValidationSummary1" runat="server" ShowMessageBox="true" ShowSummary="false"
/>
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"></asp:ToolkitScriptManager>
<asp:Panel ID="PanelFilter" runat="server" Visible="false">
<asp:Label ID="LabelFilter" runat="server" Text="Filter Criteria:" Font-Bold="true" Font-Size="Medium"
/><br />
<table>
<tr>
<td>
<asp:Label ID="LabelOrdered" runat="server" Text="Fixture Category" />
</td>
<td>
<asp:DropDownList ID="DropListCategoryFilter" runat="server"
DataSourceID="SourceFixtureCategory" DataTextField="category"
DataValueField="category" AppendDataBoundItems="true" AutoPostBack="true">
<asp:ListItem></asp:ListItem>
</asp:DropDownList>
<asp:SqlDataSource ID="SourceFixtureCategory" runat="server" ConnectionString="<%$
ConnectionStrings:ChuckAndDonsConnectionString %>"
SelectCommand="SELECT DISTINCT category FROM FixtureType">
</asp:SqlDataSource>
</td>
</tr>
<tr>
<td>

</td>
<td>

</td>
<td>
<asp:Button ID="ButtonResetFormControls" runat="server" OnClick="btnClearASP_Click"
Text="Clear Filters" Font-Bold="True" ForeColor="#FF8262" Height="30px" Width="100px"
CausesValidation="False" Font-Underline="True" />
</td>
</tr>
</table>
</asp:Panel>
<asp:Panel ID="PanelType" runat="server">
<table class="BottomMargin">
<tr>
<td style="padding-right: 4px">
<dx:ASPxButton ID="btnPdfExportAll" runat="server" Text="Export to PDF"
UseSubmitBehavior="False"
OnClick="btnPdfExport_ClickAll" ForeColor="Blue" />
</td>
<td style="padding-right: 4px">
<dx:ASPxButton ID="btnXlsxExportAll" runat="server" Text="Export to XLSX"
UseSubmitBehavior="False"
OnClick="btnXlsxExport_ClickAll" ForeColor="Blue" />
</td>
<td style="padding-right: 4px"><dx:ASPxButton ID="ASPxButtonSelect" runat="server"
Text="Select ALL rows" OnClick="ASPxButtonSelect_Click" Visible="false"></dx:ASPxButton></td>
<td style="padding-right: 150px"><dx:ASPxButton ID="ASPxButtonUNSelect" runat="server"
Text="UNSelect ALL rows" OnClick="ASPxButtonUNSelect_Click" Visible="false"></dx:ASPxButton></td>

</tr>
</table>
<dx:ASPxGridView ID="ASPxGridViewType" runat="server" ClientInstanceName="grid"
AutoGenerateColumns="False" DataSourceID="SourceFixtureType"
EnableTheming="True" KeyFieldName="fixture_type_id" Theme="MetropolisBlue" SettingsBehavior-
AutoExpandAllGroups="True"
EndCallback="OnGridEndCallback" OnCustomJSProperties="grid_CustomJSProperties" SettingsBehavior-
ProcessSelectionChangedOnServer="false">
<Columns>
<dx:GridViewCommandColumn ShowClearFilterButton="True" ShowNewButtonInHeader="True"
VisibleIndex="0">
</dx:GridViewCommandColumn>
<dx:GridViewCommandColumn ShowSelectCheckbox="True" VisibleIndex="1">
<HeaderTemplate>
<dx:ASPxCheckBox ID="cbAll" runat="server" ClientInstanceName="cbAll" ToolTip="Select
all rows" BackColor="White"
OnInit="cbAll_Init" ClientSideEvents-CheckedChanged="OnAllCheckedChanged">
<ClientSideEvents CheckedChanged="OnAllCheckedChanged" />
</dx:ASPxCheckBox>
<dx:ASPxCheckBox ID="cbPage" runat="server" ClientInstanceName="cbPage"
ToolTip="Select all rows within the page"
ClientSideEvents-CheckedChanged="OnPageCheckedChanged" OnInit="cbPage_Init">
<ClientSideEvents CheckedChanged="OnPageCheckedChanged" />
</dx:ASPxCheckBox>
</HeaderTemplate>
</dx:GridViewCommandColumn>
<dx:GridViewDataTextColumn FieldName="fixture_type_id" ReadOnly="False"
VisibleIndex="2" Caption="Fixture Type ID">
</dx:GridViewDataTextColumn>
<dx:GridViewDataComboBoxColumn FieldName="category" VisibleIndex="3" Caption="Category">
<PropertiesComboBox TextField="category" ValueField="category"
EnableSynchronization="False"
IncrementalFilteringMode="StartsWith" DataSourceID="SourceFixtureCategory">
</PropertiesComboBox>
</dx:GridViewDataComboBoxColumn>
<dx:GridViewDataTextColumn FieldName="cam" VisibleIndex="4" Caption="Mfg CAM">
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn FieldName="length_in" VisibleIndex="5" Caption="Length">
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn FieldName="depth_in" VisibleIndex="6" Caption="Depth">
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn FieldName="height_in" VisibleIndex="7" Caption="Height">
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn FieldName="mfg" VisibleIndex="8" Caption="Mfg">
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn FieldName="comments" VisibleIndex="9" Caption="Comments">
</dx:GridViewDataTextColumn>
</Columns>
<ClientSideEvents SelectionChanged="OnGridSelectionChanged" EndCallback="OnGridEndCallback" />
<Settings ShowFilterRow="True" ShowGroupPanel="True" />
<SettingsEditing Mode="Batch">
<BatchEditSettings EditMode="Cell" />
</SettingsEditing>
<Settings ShowFilterRow="True" ShowGroupPanel="True" ShowFooter="True" />
<SettingsCommandButton>
<NewButton ButtonType="Button">
</NewButton>
<EditButton ButtonType="Button">
</EditButton>
<DeleteButton ButtonType="Button">
</DeleteButton>
</SettingsCommandButton>
<Styles>
<AlternatingRow Enabled="true" />
</Styles>
</dx:ASPxGridView>
<asp:SqlDataSource ID="SourceFixtureType" runat="server"
ConnectionString="<%$ ConnectionStrings:ChuckAndDonsConnectionString %>"
DeleteCommand="DELETE FROM [FixtureType] WHERE [fixture_type_id] = @fixture_type_id"
InsertCommand="INSERT INTO [FixtureType] ([fixture_type_id], [category], [cam], [length_in],
[depth_in], [height_in], [mfg], [comments]) VALUES (@fixture_type_id, @category, @cam, @length_in,
@depth_in, @height_in, @mfg, @comments)"
SelectCommand="SELECT [fixture_type_id], [category], [cam], [length_in], [depth_in], [height_in],
[mfg], [comments] FROM [FixtureType] WHERE category=@category OR @category IS NULL"
UpdateCommand="UPDATE [FixtureType] SET [category] = @category, [cam] = @cam, [length_in] =
@length_in, [depth_in] = @depth_in, [height_in] = @height_in, [mfg] = @mfg, [comments] = @comments WHERE
[fixture_type_id] = @fixture_type_id"
CancelSelectOnNullParameter="false">
<DeleteParameters>
<asp:Parameter Name="fixture_type_id" Type="String" />
</DeleteParameters>
<InsertParameters>
<asp:Parameter Name="fixture_type_id" Type="String" />
<asp:Parameter Name="category" Type="String" />
<asp:Parameter Name="cam" Type="String" />
<asp:Parameter Name="length_in" Type="Decimal" />
<asp:Parameter Name="depth_in" Type="Decimal" />
<asp:Parameter Name="height_in" Type="Decimal" />
<asp:Parameter Name="mfg" Type="String" />
<asp:Parameter Name="comments" Type="String" />
</InsertParameters>
<SelectParameters>
<asp:ControlParameter ControlID="DropListCategoryFilter" Name="category"
PropertyName="SelectedValue" Type="String" />
</SelectParameters>
<UpdateParameters>
<asp:Parameter Name="category" Type="String" />
<asp:Parameter Name="cam" Type="String" />
<asp:Parameter Name="length_in" Type="Decimal" />
<asp:Parameter Name="depth_in" Type="Decimal" />
<asp:Parameter Name="height_in" Type="Decimal" />
<asp:Parameter Name="mfg" Type="String" />
<asp:Parameter Name="comments" Type="String" />
<asp:Parameter Name="fixture_type_id" Type="String" />
</UpdateParameters>
</asp:SqlDataSource>
<dx:ASPxGridViewExporter ID="gridExport" runat="server" GridViewID="ASPxGridViewType"
ExportedRowType="Selected" Landscape="True" RightMargin="1" LeftMargin="1">
</dx:ASPxGridViewExporter>

</asp:Panel>
</asp:Content>
[VB]
Imports Microsoft.VisualBasic
Imports System
Imports System.Web.UI
Imports System.Web.UI.WebControls.ServerValidateEventArgs
Imports System.Data.SqlClient
Imports System.Data
Imports DevExpress.Web.ASPxGridView
Imports DevExpress.Web.ASPxEditors
Partial Class CorporateForms_RealEstateFixtureType
Inherits System.Web.UI.Page
Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
Dim UserName As String = User.Identity.Name
Dim ip As String = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
'Display confirmation message
UserNameMsg.Text = String.Format(UserName)
If Not String.IsNullOrEmpty(ip) Then
Dim ipRange As String() = ip.Split(","c)
Dim le As Integer = ipRange.Length - 1
Dim trueIP As String = ipRange(le)
IPAddress.Text = String.Format(trueIP)
Else
ip = Request.ServerVariables("REMOTE_ADDR")
IPAddress.Text = String.Format(ip)
End If
End If
End Sub
Protected Sub btnClearASP_Click(ByVal sender As Object, ByVal e As EventArgs)
ResetFormControlValues(Me)
End Sub
Sub ResetFormControlValues(ByVal parent As Control)
For Each c As Control In parent.Controls
If c.Controls.Count > 0 Then
ResetFormControlValues(c)
Else
Select Case c.[GetType]().ToString()
Case "System.Web.UI.WebControls.TextBox"
DirectCast(c, TextBox).Text = ""
Exit Select
Case "System.Web.UI.WebControls.CheckBox"
DirectCast(c, CheckBox).Checked = False
Exit Select
Case "System.Web.UI.WebControls.RadioButton"
DirectCast(c, RadioButton).Checked = False
Exit Select
Case "System.Web.UI.WebControls.DropDownList"
DirectCast(c, DropDownList).SelectedIndex = -1
Exit Select
End Select
End If
Next
End Sub
Protected Sub ASPxButtonSelect_Click(ByVal sender As Object, ByVal e As EventArgs)
ASPxGridViewType.Selection.SelectAll()
End Sub
Protected Sub ASPxButtonUNSelect_Click(ByVal sender As Object, ByVal e As EventArgs)
ASPxGridViewType.Selection.UnselectAll()
End Sub
Protected Sub cbAll_Init(ByVal sender As Object, ByVal e As EventArgs)
Dim chk As ASPxCheckBox = TryCast(sender, ASPxCheckBox)
Dim grid As ASPxGridView = (TryCast(chk.NamingContainer, GridViewHeaderTemplateContainer)).Grid
chk.Checked = (grid.Selection.Count = grid.VisibleRowCount)
End Sub
Protected Sub cbPage_Init(ByVal sender As Object, ByVal e As EventArgs)
Dim chk As ASPxCheckBox = TryCast(sender, ASPxCheckBox)
Dim grid As ASPxGridView = (TryCast(chk.NamingContainer, GridViewHeaderTemplateContainer)).Grid

Dim cbChecked As Boolean = True


Dim start As Int32 = grid.VisibleStartIndex
Dim [end] As Int32 = grid.VisibleStartIndex + grid.SettingsPager.PageSize
[end] = (If([end] > grid.VisibleRowCount, grid.VisibleRowCount, [end]))

For i As Integer = start To [end] - 1


If (Not grid.Selection.IsRowSelected(i)) Then
cbChecked = False
Exit For
End If
Next i
chk.Checked = cbChecked
End Sub
Protected Sub grid_CustomJSProperties(ByVal sender As Object, ByVal e As
ASPxGridViewClientJSPropertiesEventArgs)
Dim grid As ASPxGridView = TryCast(sender, ASPxGridView)

Dim start As Int32 = grid.VisibleStartIndex


Dim [end] As Int32 = grid.VisibleStartIndex + grid.SettingsPager.PageSize
Dim selectNumbers As Int32 = 0
[end] = (If([end] > grid.VisibleRowCount, grid.VisibleRowCount, [end]))

For i As Integer = start To [end] - 1


If grid.Selection.IsRowSelected(i) Then
selectNumbers += 1
End If
Next i

e.Properties("cpSelectedRowsOnPage") = selectNumbers
e.Properties("cpVisibleRowCount") = grid.VisibleRowCount
End Sub

Sub HideColumnsAll(ByVal show As Boolean)

End Sub
Protected Sub btnPdfExport_ClickAll(ByVal sender As Object, ByVal e As EventArgs)
HideColumnsAll(True)
gridExport.WritePdfToResponse()
HideColumnsAll(False)
End Sub
Protected Sub btnXlsxExport_ClickAll(ByVal sender As Object, ByVal e As EventArgs)
HideColumnsAll(True)
gridExport.WriteXlsxToResponse()
HideColumnsAll(False)
End Sub
End Class

You might also like