找回密码
 注册
搜索
热搜: 回贴

ASP.NET简单应用

2009-12-13 13:30| 发布者: admin| 查看: 60| 评论: 0|原作者: 琴姬

□连接数据库 ......


连接数据库




打开连接
string connstr=System.Configuration.ConfigurationSettings.AppSettings["sqllink"];
SqlConnection conn=new SqlConnection(connstr);
conn.Open();
添加DataGrid
SqlDataAdapter dr=new SqlDataAdapter(sqlstr,conn);
DataSet ds=new DataSet();
dr.Fill(ds,"usract");
if(Convert.ToInt32(ds.Tables["ContList"].Rows.Count.ToString())==0)
{
this.DataGrid1.ShowFooter=true;
}
this.DataGrid1.DataSource=ds.Tables["usract"].DefaultView;
this.DataGrid1.DataBind();
ADO.NET应用
string sql="select count(*) as icount from sysoper where logname='"+this.usrname.Text+"'";
SqlCommand comm=new SqlCommand(sql,conn);
SqlDataReader dr1=comm.ExecuteReader();
dr1.Read();
string count=dr1["icount"].ToString();
dr1.Close();
panel显示条

DIV滚动条



enconding加密
System.Web.HttpUtility.UrlEncode(this.txtgrpid.Text.Trim())
System.Web.HttpUtility.HtmlDecode(Request.QueryString["grpid"])
vs.net2003和vs.net2005 b2的使用
用2003
c:\WINNT\Microsoft.NET\Framework\v1.1.4322\aspnet_regiis.exe -i
c:\WINNT\Microsoft.NET\Framework\v1.1.4322\aspnet_regiis.exe -r
用2005
c:\WINNT\Microsoft.NET\Framework\v2.0.50215\aspnet_regiis.exe -i
c:\WINNT\Microsoft.NET\Framework\v2.0.50215\aspnet_regiis.exe -r
IIS注册
C:\>\WINNT\Microsoft.NET\Framework\v1.1.4322\aspnet_regiis -i
开始安装 ASP.NET (1.1.4322.0)。
已安装完 ASP.NET (1.1.4322.0)。
regsvr32 C:\WINNT\Microsoft.NET\Framework\v1.1.4322\aspnet_isapi.dll
webform调用windowsfrom
if (MessageBox.Show("确定要删除?", "提示",MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation,MessageBoxDefaultButton.Button1,
MessageBoxOptions.ServiceNotification )==DialogResult.OK)
{//do some useful things }
//调用using System.Windows.Forms;这个包
表格强行换行

表格中的字符全是数字,或者字母,或者数字和字母,默认是不换行的.上面的是换行的
动态生成DataGrid
BoundColumn column1=new BoundColumn();
column1.HeaderText="登陆名称";
column1.DataField="UsrName";
column1.HeaderStyle.Wrap=false;
column1.ItemStyle.Wrap=false;
//column1.Visible=true;
column1.HeaderStyle.HorizontalAlign=HorizontalAlign.Center;
this.DataGrid1.Columns.Add(column1);
HyperLinkColumn linkcolumn1=new HyperLinkColumn();
linkcolumn1.DataNavigateUrlField="actid";
linkcolumn1.HeaderText="修改";
linkcolumn1.Text="开始修改";
//linkcolumn1.DataNavigateUrlFormatString="edit_usr.aspx?actid='+e.Item.Cells[0].Text+'&grpid='+e.Item.Cells[4].Text+'&pnltype='++System.Web.HttpUtility.
UrlEncode(e.Item.Cell[3].Text)++'";//this.Response.Write("window.location.href='edit_usr.aspx?actid="+this.txtactid.Text.Trim()+"&grpid="+this.txtgrpid.Text.Trim()+"&pnltype="+System.Web.HttpUtility.
UrlEncode(this.actidgrpid.Text.Trim())+"'");
//linkcolumn1.DataNavigateUrlFormatString="edit_usr.aspx?actid={0}&grpid={4}";
//只能传一个值是键
linkcolumn1.HeaderStyle.Wrap=false;
linkcolumn1.ItemStyle.Wrap=false;
linkcolumn1.Visible=true;
linkcolumn1.HeaderStyle.HorizontalAlign=HorizontalAlign.Center;
linkcolumn1.ItemStyle.HorizontalAlign=HorizontalAlign.Center;
this.DataGrid1.Columns.Add(linkcolumn1);
时间格式
d 月中的某一天。一位数的日期没有前导零。
dd 月中的某一天。一位数的日期有一个前导零。
ddd 周中某天的缩写名称,在 AbbreviatedDayNames 中定义。
dddd 周中某天的完整名称,在 DayNames 中定义。
M 月份数字。一位数的月份没有前导零。
MM 月份数字。一位数的月份有一个前导零。
MMM 月份的缩写名称,在 AbbreviatedMonthNames 中定义。
MMMM 月份的完整名称,在 MonthNames 中定义。
y 不包含纪元的年份。如果不包含纪元的年份小于 10,则显示不具有前导零的年份。
yy 不包含纪元的年份。如果不包含纪元的年份小于 10,则显示具有前导零的年份。
yyyy 包括纪元的四位数的年份。
gg 时期或纪元。如果要设置格式的日期不具有关联的时期或纪元字符串,则忽略该模式。
h 12 小时制的小时。一位数的小时数没有前导零。
hh 12 小时制的小时。一位数的小时数有前导零。
H 24 小时制的小时。一位数的小时数没有前导零。
HH 24 小时制的小时。一位数的小时数有前导零。
m 分钟。一位数的分钟数没有前导零。
mm 分钟。一位数的分钟数有一个前导零。
s 秒。一位数的秒数没有前导零。
ss 秒。一位数的秒数有一个前导零

最新评论

QQ|小黑屋|最新主题|手机版|微赢网络技术论坛 ( 苏ICP备08020429号 )

GMT+8, 2024-9-29 23:27 , Processed in 0.156266 second(s), 12 queries , Gzip On, MemCache On.

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.