· 文件上传部分代码
2008-9-3 22:44:53 阅读90 评论0 32008/09 Sept3
DataKeyNames:获取或设置一个数组,该数组包含了显示在 GridView 控件中的项的主键字段的名称。
注意其是数组类型使用时:GridView1.DataKeyNames = new string[] { "id" };
例如: this.GridView1.DataKeyNames = new string[] { "petID" }; petID 为数据表主键
DataKeys:获取一个 DataKey 对象集合,这些对象表示 GridView 控件中的每一行的数据键值。
//获取第i行的id键值,注意该索引即行的索引,从header到footer都算在内
2008-8-28 13:47:07 阅读229 评论0 282008/08 Aug28
2008-8-27 20:11:14 阅读10 评论0 272008/08 Aug27
验证用户名是否已存在CustomValidator
string username = args.Value;
SqlConnection con = new SqlConnection("server=.;database=login;uid=sa;pwd=;");
con.Open();
SqlCommand com = new SqlCommand("select count(*) from login where username= '"+username+"'",con);
int count = Convert.ToInt32(com.ExecuteScalar());
2008-8-27 19:10:12 阅读11 评论0 272008/08 Aug27
2008-8-26 15:15:50 阅读25 评论0 262008/08 Aug26
if (!IsPostBack)
{
SqlConnection con = sql.createConnection();
con.Open();
SqlCommand cmd = new SqlCommand("select voteTitle from voteMaster where voteID=" + this.voteID, con);
string title = Convert.ToString(cmd.ExecuteScalar());