个人的web开发心得(六)----------非常适合入门新手,都是常识
54.清空数据库表的记录
--打开库
use serp
--清空表
truncate table month_result
55.将某部分内容 放到 panel中 可以 添加 滚动条,控制 该区域大小
<asp:Panel ID="Panel1" runat="server" Height="100%" ScrollBars="Auto" Width="100%"> //添加左右 上下 两个滚动条
<asp:Panel ID="Panel2" runat="server" Height="43px" Width="98%" ScrollBars="Vertical"> //只添加 上下滚动条。
57.用函数向cookic中存储用户标识 ,
FormsAuthentication.RedirectFromLoginPage(name, false);
name=User.Identity.Name;读取cookic的数据
作用等同于:
cookic["name"]="dwj";
name=cookic["name"].tostring();
58. string.Format使用
string sql = " select username from userinfo where username='{0}' and password='{1}'";
sql = string.Format(sql, Name.Text.Trim(), PassWord.Text.Trim());
59. 索引器的使用 类似 属性。
/// <summary>
/// 通过索引器获取查询参数
/// </summary>
public SqlParameter this[int index]
{
get
{
return this.List[index] as SqlParameter;
}
}
/// <summary>
/// 通过索引器获取查询参数 最有用的地方 SqlParameter[]不能根据字符串索引
/// </summary>
public SqlParameter this[string parameterName]
{
get
{
return this.m_paramsHash[parameterName] as SqlParameter;
}
}
/// <summary>
/// 将集合转换成数组
/// </summary>
/// <returns>SqlParameter 数组</returns>
public SqlParameter[] ToArray()
{
return (SqlParameter[])ArrayList.Adapter(this.List).ToArray(
typeof(System.Data.SqlClient.SqlParameter));
}
60.
由上面的代码可知
List 索引时 只能 按照 index 获取List中的内容
如: string temp=List[1].tostring();
this.List.Add(parameter);
Hashtable 索引的时候能够根据 name 获取Hashtable的内容
如: string temp=Hashtable["name"].tostring();
this.m_paramsHash.Add(parameter.ParameterName, parameter);