1.关于DATASET中rowfilter的使用问题
在DATASET中,想要使用rowfilter
select .OrderID,o.OrderTime,o.OrderAmount,o.OrderNumber,cr.UserName,cr.ContactPhone,cr.DetailAddress from C_CustomerRoute as cr,O_Order as o
where cr.CustomerRouteID=o.CustomerRouteID
上面的SQL语句用来填充DATASET,但想要在ROWFILTER中实现下面的功能
and datepart(day,OrderTime)=datepart(day,getdate())
这句已经在查询分析器里运行过,没有错误。要把这句放到ROWFILTER里怎么写呢?
比如: GetDataTable() {
DataTable dt1 = dt.copy();
foreach(DataRow dr in dt.rows)
{
//取出OrderDate的Day并与当前时间的天做比较。相同就把dr放到dt1中
}
return dt1;
}
rowfilter中不能使用别名 rowfilter = "c.useid = 'ww' "[错误的]
2.有关于动态加载隐藏域和动态取得隐藏域的值与页面的下拉框的中的值来进行比较。
第1种:.在页面中事先写好隐藏域。
<form>
<asp:HiddenField ID="year" runat="server" />
<asp:HiddenField ID="month" runat="server" />
</form>
然后在CodeFile文件中的page_load中对其进行动态赋值
this.year.Value = DateTime.Now.Year.ToString();
this.month.Value = DateTime.Now.Month.ToString();
最后在到客户端动态取得year,month
document.form.year.value
document.form.month.value
第二种:在codefile文件中page_load中进行动态加载隐藏域
使用literal控件装载隐藏域
this.libAddHidden.Text =" <asp:HiddenField ID=/"year/" value=/"2006/" runat=/"server/" />"+
"<asp:HiddenField ID=/"month/" value=/"6/" runat=/"server/" />";
这时可以发现在客户端在源码中在page_load中加载的asp:HiddenField 没有转变成 input type="hidden"的形式,
这时如果想取得没有转变的隐藏域的值,可以使用
document.getElementById("year").value
document.getElementById("month").value
如果使用以下的取值方式就不对了
//document.form.year.value
//document.form.month.value
反则:如果动态加载到literal控件中的是客户端的input type="hidden"的话,就可以使用任意一种取值方式,即可
3.JS控制输入
<input οnkeyup="value=value.replace(/[^/u4E00-/u9FA5]/g,'')" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^/u4E00-/u9FA5]/g,''))">只能输入汉字
<input οnkeyup="value=value.replace(/[^/uFF00-/uFFFF]/g,'')" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^/uFF00-/uFFFF]/g,''))">只能输入全角
<input οnkeyup="value=value.replace(/[^/d]/g,'') "onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^/d]/g,''))">只能输入数字
<input οnkeyup="value=value.replace(/[/W]/g,'') "onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^/d]/g,''))">只能输入英文和数字
<input οnkeyup="value=value.replace(/[^/cd-/cd]/g,'')" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^/cd-/cd]/g,''))">什么都不能输入
<input οnkeyup="value=value.replace(/[^/gb-/gb]/g,'')" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^/gb-/gb]/g,''))">只能输入这几个字母egfdcb
4.server.Transfer与response.Redirect的作用都是重定向,我认为它与response.Redirect相比有两个优点、一个缺点。
优点:
一、它在服务器端直接重定向,不用像response.Redirect一样先与浏览器通信再重定向,效率高。
二、它可以传递上一个页面的提交值。比如:A页面提交值到B页面,B页面Transfer到C页面,C页面同样可以收到A页面提交的值。
缺点:(2006-1-10修改)
不能刷新页面,比如:A页面提交登录信息到B页面,B页面处理后Transfer再到A,A页面得不到刷新,指定了过期也不行。如果A、B页面不在同一个目录下,我们还会发现更多意想不到的结果,使用相对链接的图片、超链接的指向都改变了,造成这种原因是B页面读取A页面内容却以B页面的身份输出,所以路径改变了。
说到server.transfer,就不得不说server.execute,这两个东西有点类似。主要的区别在于,server.execute在第二个页面结束执行后,还会返回第一个页面继续处理.
同时,使用Server.Transfer时应注意一点:目标页面将使用原始页面创建的应答流(就是跳转本身的页面),这导致ASP.NET的机器验证检查(Machine Authentication Check,MAC)认为新页面的ViewState已被篡改。因此,如果要保留原始页面的表单数据和查询字符串集合,必须把目标页面Page指令的EnableViewStateMac属性设置成False。
5.C#页面中判断绑定上来的值是否为空
<asp:TemplateField>
<ItemTemplate>
<%# DataBinder.Eval(Container.DataItem, "IDCardTypeName").ToString().Equals("") ?"其他":DataBinder.Eval(Container.DataItem, "IDCardTypeName")%>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField HeaderText="Type" DataField="IDCardTypeName">
<HeaderStyle Font-Bold="False" />
</asp:BoundField>
VB.net
<input id="txtPW" onBlur="javascript:formatNumberClient(this);" onFocus="javascript:unformatNumberClient(this,'on');" size=12 value='<%# IIF(isdbnull(ctype(DataBinder.Eval(Container.DataItem,"PostWage"),object)),"0.00",format(cdbl(IIF(isdbnull(DataBinder.Eval(Container.DataItem,"PostWage")),0,DataBinder.Eval(Container.DataItem,"PostWage"))),"##,##0.00")) %>' type="text" MaxLength="9" runat="server" NAME="txtPW" style="text-align:right" >
6.引用另一个工程的文件夹里的文件可以用<%=Application["项目工程名Path"]%> /JS/**.js
7.判断JS传过来的值,并返回不带空格的完整日期
传过来的值有三种形式:
1.1900-1-1 00:00:00
2.1900-11-1 20:00:00
3.1900-12-18 10:00:00以下是判断的代码
if(sIdB.substr(8,1) != '' && (sIdB.substr(9,1) == '0' || sIdB.substr(9,1) == '1' || sIdB.substr(9,1) == '2'))
{
//返回到前一个窗口的值
eval("window.opener.document.aspnetForm.birth"+j+".value='"+sIdB.substr(0,8)+"'");
}
else if(sIdB.substr(9,1)!='' && (sIdB.substr(10,1) == '0' || sIdB.substr(10,1) == '1' || sIdB.substr(10,1) == '2'))
{
eval("window.opener.document.aspnetForm.birth"+j+".value='"+sIdB.substr(0,9)+"'");
}
else if(sIdB.substr(10,1)!='' && (sIdB.substr(11,1) == '0' || sIdB.substr(11,1) == '1' || sIdB.substr(11,1) == '2'))
{
eval("window.opener.document.aspnetForm.birth"+j+".value='"+sIdB.substr(0,10)+"'");
}
8.RowFilter中不能使用between and 只能用>= and <=代替
9.获得任意窗体的实例化句柄
_Default wf1 = (_Default)Context.Handler;
10.DataGridView隔行换色的属性
获取或设置应用于 DataGridView 的奇数行的默认单元格样式。
dataGridView1.AlternatingRowsDefaultCellStyle.BackColor = Color.DarkGray;
11.System.Configuration.ConfigurationErrorsException: The requested database IT-014-211952_FltOrderDB_SELECT is not defined in configuration.
是由于webconfig 没有正确config <connectionStrings configSource="Config//DataBaseTest.config" />
12. IE与FireFox兼容性的问题
StringBuilder sb = new StringBuilder();
IE

2

3

FireFox中必须加上<html><body>。。。</body></html>

2

3

在FireFox中javascript最好包在<body>。。</body>中,不然会有一些问题。
13.c#里string 与char数组怎么转换
string yb = "abc";
char[] yy = yb.ToCharArray()
14.判断是页面上已经动态加载过javascript了
if (!Page.IsStartupScriptRegistered("javascriptKey"))
{
System.Text.StringBuilder vScripts = new System.Text.StringBuilder(2000);
vScripts.Append("<script language=/"javascript/"> alert('test')</script>");
Page.RegisterStartupScript("javascriptKey", vScripts.ToString());
}
15.
我在IE地址框中输入一个新的URL地址后,返回的还是当前页面,请问该如何清除客户端的缓存呢?? | |||||||||
Response.Buffer=true; | |||||||||
Response.ExpiresAbsolute=System.DateTime.Now.AddSeconds(-1); | |||||||||
Response.Expires=0; | |||||||||
Response.CacheControl="no-cache"; | |||||||||
HTM网页 | |||||||||
<META HTTP-EQUIV="pragma" CONTENT="no-cache"> | |||||||||
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache, must-revalidate"> | |||||||||
<META HTTP-EQUIV="expires" CONTENT="Wed, 26 Feb 1997 08:21:57 GMT"> |