未整理笔记
ASPxGridView
1.//ASPxGridView前台获取行号
<ClientSideEvents RowClick="function(s, e) {
s.GetRowKey(e.visibleIndex);
}"
/>
2.在后台动绑定gridview的列
绑定列不能直接对象调用修改内部属性(原理:定义的所有列都是父类gridviewdatacolumn类,并不是直接定义子类)。
比如列为<gridviewdataComboBoxcolumn>,需要后台先定义一个
gridviewdataComboBoxcolumn column1=gridview.Columns["修改的列"] as gridviewdataComboBoxcolumn;
之后 用column1来定义:column1.PropertiesComboBox.DataSource=datasource1;(自己定义数据源)
其他的列类型写法一样
绑定列要写在绑定gridview之前
3.ASPxGridView进入选中行后台事件必须设置<SettingsBehavior ProcessSelectionChangedOnServer="true" /> 想要刷新页面,设置EnableCallBacks="false"
<SettingsBehavior AllowFocusedRow="true" 选中行 EnableRowHotTrack="true" 跟随鼠标移动
/>
4.Gridview中行字符多显示省略号
<SettingsBehavior AllowEllipsisInText="true"/>
5.列的宽度的拖动
SettingsResizing-ColumnResizeMode="NextColumn"
- 下拉框选中后允许为空
<PropertiesComboBox AllowNull="true"></PropertiesComboBox>
var rowindex= grid.GetFocusedRowIndex();//获取选中行行号
var rowid= grid.GetRowKey(rowindex);//根据行号获取rowid
设置修改行中一列的值 gridApp.SetEditValue(9, names);
ShowStatusBar="Hidden" 不显示自带的保存取消按钮
Settings-GridLines="None" 显示行的边框和列的边框
7.当使用皮肤Office365时行的横向边框不会显示,在Page_Load中加入以下代码可以显示边框
grdPeriod.Settings.GridLines = (GridLines)Enum.Parse(typeof(GridLines), "Both", true);
ASPxComboBox
1.控件前台属性AutoPostBack="true"才能触发后台事件
2.ASPxComboBox前台指定数据后台可以进事件,必须后台页面加载时给一个数据库的值
<dx:ASPxComboBox ID="ComboBoxDatetype" runat="server" OnSelectedIndexChanged="ComboBoxDatetype_SelectedIndexChanged" AutoPostBack="true">
<Items>
<dx:ListEditItem Text="表" Value="1" />
<dx:ListEditItem Text="字典" Value="0" />
</Items>
</dx:ASPxComboBox>
protected void Bind()
{
string sql = @"select exCtrl from Base_TblField GROUP BY exCtrl";
DataTable dt_ctrl = APIcall.GetDataTableBysql(sql);
this.ComboBoxDatetype.Text = dt.Rows[0]["exUptCtrlType"].ToString() == "1" ? "表" : "字典";
}
protected void ComboBoxDatetype_SelectedIndexChanged(object sender, EventArgs e)
{
//可以进,也可以刷新
}
Carsview
中卡片的高度设置
Styles-Card-Height="100"
20.找控件之中的控件
ASPxListBox listbox = ASPxDropDownEdit1.FindControl("listBox") as ASPxListBox;
21.Json序列化和反序列化
引用Newtonsoft.Json DLL
添加using Newtonsoft.Json;命名空间
JsonConvert.SerializeObject(dt) //DataTable序列化为json
//反序列化 str1为Json字符串
DataTable dt = Newtonsoft.Json.JsonConvert.DeserializeObject(str1, typeof(DataTable)) as DataTable;
22.读取网页(HTTP/HTTPS)内容
引用System.Net.Http DLL
添加using System.Net.Http;命名空间
HttpClient client = new HttpClient();
var task = client.GetAsync(url)
23.sql语句查询实体字段的属性说明(描述)等
SELECT obj.name AS 表名,
col.colorder AS 序号 ,
col.name AS 列名 ,
ISNULL(ep.[value], '') AS 列说明 ,
t.name AS 数据类型 ,
col.length AS 长度 ,
ISNULL(COLUMNPROPERTY(col.id, col.name, 'Scale'), 0) AS 小数位数 ,
CASE WHEN COLUMNPROPERTY(col.id, col.name, 'IsIdentity') = 1 THEN '√'
ELSE ''
END AS 标识 ,
CASE WHEN EXISTS ( SELECT 1
FROM dbo.sysindexes si
INNER JOIN dbo.sysindexkeys sik ON si.id = sik.id
AND si.indid = sik.indid
INNER JOIN dbo.syscolumns sc ON sc.id = sik.id
AND sc.colid = sik.colid
INNER JOIN dbo.sysobjects so ON so.name = si.name
AND so.xtype = 'PK'
WHERE sc.id = col.id
AND sc.colid = col.colid ) THEN '√'
ELSE '0'
END AS 主键 ,
CASE WHEN col.isnullable = 1 THEN '1'
ELSE '0'
END AS 允许空 ,
ISNULL(comm.text, '') AS 默认值
FROM dbo.syscolumns col
LEFT JOIN dbo.systypes t ON col.xtype = t.xusertype
inner JOIN dbo.sysobjects obj ON col.id = obj.id
AND obj.xtype = 'U'
AND obj.status >= 0
LEFT JOIN dbo.syscomments comm ON col.cdefault = comm.id
LEFT JOIN sys.extended_properties ep ON col.id = ep.major_id
AND col.colid = ep.minor_id
AND ep.name = 'MS_Description'
LEFT JOIN sys.extended_properties epTwo ON obj.id = epTwo.major_id
AND epTwo.minor_id = 0
AND epTwo.name = 'MS_Description'
WHERE obj.name LIKE
'cishis%'--表名
ORDER BY obj.name
24.gridview列拖动,自带确认取消编辑按钮等属性
<SettingsResizing ColumnResizeMode="NextColumn" /> 列拖动
<Settings ShowStatusBar="Hidden" /> 自带编辑确认按钮
<SettingsEditing Mode="Batch">
<BatchEditSettings EditMode="Row" />
</SettingsEditing> 编辑形式,双击进入编辑
25.c#隐藏按钮文本框时不能使用Enabled这种后台属性,要使用ClientEnabled这种前台属性,不然在前台会获取不到这个控件
26.DX控件前台获文本框的值和前台设置label的值
var sss = Text_Name.GetText(); //获取
var c = ASPxClientLabel.Cast(ASPxLabel12);//设置
c.SetText("年项目进度对比图");
27.Sql查询两个字段合并组合成一个字段
SELECT tblname , tbldesc ,('['+tbldesc+']'+ tblname) AS name FROM _Base_TblList
28.Sql查询节点下面所有的子节点
WITH f AS(SELECT * FROM BASE_AppModleList WHERE rowid='D6EB537E81CC4176AC2AA66C010A2C94'
UNION ALL SELECT a.* FROM BASE_AppModleList AS a JOIN f AS b ON a.prowid=b.rowid)
SELECT * FROM f
29.Dx控件To work properly, DevExpress components require ASPxHttpHandlerModule registered in the web.config file. For details, see: http://documentation.devexpress.com/#AspNet/CustomDocument7540 问题
iis低版本webconfig中加入
<httpModules>
<add type="DevExpress.Web.ASPxHttpHandlerModule, DevExpress.Web.v16.2, Version=16.2.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" name="ASPxHttpHandlerModule" />
</httpModules>
<httpHandlers>
<add type="DevExpress.Web.ASPxHttpHandlerModule, DevExpress.Web.v16.2, Version=16.2.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" verb="GET,POST" path="DX.ashx" validate="false" />
<add verb="GET,POST" path="ASPxUploadProgressHandlerPage.ashx" type="DevExpress.Web.ASPxUploadProgressHttpHandler, DevExpress.Web.v16.2, Version=16.2.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" />
</httpHandlers>
Iis7版本webconfig中加入
<system.web>
<httpModules>
<add type="DevExpress.Web.ASPxHttpHandlerModule, DevExpress.Web.v16.2, Version=16.2.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" name="ASPxHttpHandlerModule" />
</httpModules>
<httpHandlers>
<add type="DevExpress.Web.ASPxHttpHandlerModule, DevExpress.Web.v16.2, Version=16.2.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" verb="GET,POST" path="DX.ashx" validate="false" />
<add verb="GET,POST" path="ASPxUploadProgressHandlerPage.ashx" type="DevExpress.Web.ASPxUploadProgressHttpHandler, DevExpress.Web.v16.2, Version=16.2.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" />
</httpHandlers>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<handlers>
<add type="DevExpress.Web.ASPxHttpHandlerModule, DevExpress.Web.v16.2, Version=16.2.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" verb="GET,POST" name="ASPxHttpHandlerModule" path="DX.ashx" preCondition="integratedMode" />
</handlers>
<modules>
<add type="DevExpress.Web.ASPxHttpHandlerModule, DevExpress.Web.v16.2, Version=16.2.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" name="ASPxHttpHandlerModule"/>
</modules>
</system.webServer>
新的实验结果:
<httpModules>
<add type="DevExpress.Web.ASPxHttpHandlerModule, DevExpress.Web.v18.1, Version=18.1.2.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" name="ASPxHttpHandlerModule" />
</httpModules>
<system.webServer>
<modules>
<add type="DevExpress.Web.ASPxHttpHandlerModule, DevExpress.Web.v18.1, Version=18.1.2.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" name="ASPxHttpHandlerModule" />
</modules>
<validation validateIntegratedModeConfiguration="false" />
<handlers>
<add type="DevExpress.Web.ASPxHttpHandlerModule, DevExpress.Web.v18.1, Version=18.1.2.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" verb="GET" path="DX.ashx" name="ASPxHttpHandlerModule" preCondition="integratedMode" />
</handlers>
</system.webServer>
Webconfig中加入以下语句,页面中就不用引用dev了
<pages validateRequest="false" controlRenderingCompatibilityVersion="4.0" clientIDMode="AutoID">
<controls>
<add assembly="DevExpress.Web.v18.1, Version=18.1.2.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web" tagPrefix="dx"/>
</controls>
</pages>
30.Sql查询节点下面所有的子节点并且组成标题(1 1.1 1.2.1 )
WITH f AS(SELECT * FROM BASE_AppModleList WHERE rowid='D6EB537E81CC4176AC2AA66C010A2C94'
UNION ALL SELECT a.* FROM BASE_AppModleList AS a JOIN f AS b ON a.prowid=b.rowid)
SELECT * FROM f
with t1 as (
SELECT [rowid],[prowid],[ModName], substring(Cast((10000+DENSE_RANK() OVER (ORDER BY rowid)) as varchar(max)) ,2,4)AS INDEs ,Cast((DENSE_RANK() OVER (ORDER BY rowid)) as varchar(max)) AS INDE FROM [BASE_AppModleList] Where prowid='000000' AND [state]='0'
union all
SELECT t2.[rowid],T2.[prowid],T2.[ModName],(T1.INDEs +'.'+SUBSTRING( Cast((10000+DENSE_RANK() OVER (ORDER BY t2.rowid)) as varchar(max)),2,4) ) as INDEs ,(T1.INDE +'.'+ Cast((DENSE_RANK() OVER (ORDER BY t2.rowid)) as varchar(max))) as INDE
from [BASE_AppModleList] t2
inner Join t1 on t2.[prowid]=t1.[rowid])
select * from t1 ORDER BY INDEs
31.文本框不能为空约束
<dx:ASPxSpinEdit ID="ASPxSpinEdit1" Enabled="false" runat="server" Number="0">
<ValidationSettings Display="Dynamic" ErrorText="不能为空!" ErrorTextPosition="Bottom">
<ErrorImage IconID="support_suggestion_16x16office2013">
</ErrorImage>
<RequiredField ErrorText="" IsRequired="True" />
</ValidationSettings>
</dx:ASPxSpinEdit>
- 获取字符串中字符的位置(不区分大小写)
var ii = sql.IndexOf("view", StringComparison.CurrentCultureIgnoreCase);
33.获取数据库中字段的一些属性、中文名、默认值等
select c.name as ColumnName , t.name as DataType, c.object_id,c.max_length , c.is_nullable , d.definition,ISNULL(ep.[value], '') AS 列说明, CASE WHEN EXISTS(SELECT 1 FROM
dbo.sysindexes si INNER JOIN dbo.sysindexkeys sik ON si.id = sik.id AND si.indid = sik.indid
INNER JOIN dbo.syscolumns sc ON sc.id = sik.id AND sc.colid = sik.colid
INNER JOIN dbo.sysobjects so ON so.name = si.name AND so.xtype = 'PK'
WHERE sc.id = c.[object_id] AND sc.colid = c.column_id) THEN '1' ELSE '0' END AS 主键
from sys.COLUMNS c join sys.types t on c.system_type_id = t.user_type_id
LEFT JOIN sys.default_constraints d ON c.default_object_id = d.object_id
LEFT JOIN sys.extended_properties ep ON c.[object_id] = ep.major_id AND c.column_id= ep.minor_id AND ep.name = 'MS_Description' WHERE c.object_id='222623836'
34.获取Gridview行的行号根据主键
grdList.FindVisibleIndexByKeyValue
35.显示treeview节点选中状态
AllowSelectNode="true"
36.Treeviewlist的属性及方法
navtree.ExpandToLevel(2);//树展开到第几级 后台设置属性
37.找出一个数组在另一个数组没有的元素
string[] p = new[] { "a","b"}
string[] c = new[] { "a","b","c"}
string list_deve = string.Empty;
foreach (string item in c)
{
if (Array.IndexOf(p, item) < 0)
{
list_deve += "," + item;
}
}
38.查表中tblname字段数据含有’testTable1’或’testTable2’的记录(用逗号分隔更准确)
SELECT * FROM dbo.Base_TblField WHERE CHARINDEX(','+tblname+',' , ',testTable1,testTable2,')>0
39.ASPxPopupControl中的属性
Maximized 窗口最大化(设置为true时窗口直接变成最大)
PopupHorizontalAlign 水平的居中显示
PopupVerticalAlign 垂直的居中显示
CloseAction="CloseButton" 弹框之后不能点击其他地方
AllowDragging 能否拖动
ShowMaximizeButton 显示最大化按钮
PopupAnimationType 弹框方式
40.ASPxPopupControl的弹框在
ASPxGridView的列中没有GridViewDataComboBoxColumn
点击事件是GridViewCommandColumn中按钮触发,
本页面没有ASPxPopupControl控件时不能获取到ASPxClientPopupControl.Cast(window.top.ASPxPopupControl1)用window.parent获取也不行
41.前台定义一个数组
var mycars = new Array();
mycars[0] = "Saab";
mycars[1] = "Volvo";
mycars[2] = "BMW";
42.文本框不能为空属性 Display="Dynamic"提示文字开始不占位置 为Static则占位置
IsRequired="true" 启用验证 为false不启用
<dx:ASPxTextBox ID="txtName" runat="server" Width="300px">
<ValidationSettings ErrorTextPosition="Bottom" Display="Dynamic">
<RequiredField ErrorText="名称不能为空!" IsRequired="true" />
</ValidationSettings>
</dx:ASPxTextBox>