用gridview 更新和删除 需要 唯一的主键 city_id
但是邦定时用this.gridview1.datakeynames="City_Name"; 出现CS0029: 无法将类型“string”隐式转换为“string[]”
然后改成: this.gridview1.datakeynames="City_Name".toString();
也是一样错误救命啊
解决方案 »
- 很菜的FLASH问题~~麻烦解决一下(会FLASH的都能搞定)~~~
- 一段html代码 看不懂 请高手解释
- 如何使DropDownList中的一项显示出来,但又不能被选中
- (在线)像类似2005-02-10日期格式的正则表达式怎么写?
- asp.net的debug问题
- 关于ASP.NET的几点疑问
- [求助]请各位帮忙解答RadioButtonList或CheckButtonList生成
- 再代码绑定中 怎样动态装载 userControl,谢谢大家帮忙!!
- 按钮菜单问题
- 软件行业最低级的工作就是asp。
- 请教关于DataSet中添加DataTable的问题(C#)
- asp.net 如何读.txt文件
conn.Open();
string sqlstr = "select City_ID,City_Name from city order by City_ID DESC";
SqlDataAdapter da=new SqlDataAdapter(sqlstr,conn);
DataSet ds=new DataSet();
da.Fill(ds,"city");
this.GridView1.DataKeyNames="City_ID".ToString();
this.GridView1.DataSource = ds.Tables[0];
this.GridView1.DataBind();
conn.Close();
GridView1.DataKeyNames = new string[] { "City_ID" };
GridView1.DataKeyNames = new string[] { "City_ID" };
太正确了。2005的DataKeyNames是一个数组。