before you bind the datatable to the datagrid, add an additional column:DataTable1.Columns.Add("newkey",typeof(string), "字段1 + '#' + 字段2");then doDataGrid1.DataKeyField = "newkey";
...then you can dostring s = DataGrid1.DataKeys[nItemIndex];
string[] sKeys = s.Split('#');
....
...then you can dostring s = DataGrid1.DataKeys[nItemIndex];
string[] sKeys = s.Split('#');
....
解决方案 »
- 一个很简单的问题,数字后面的字母有哪些?
- 连接 sqlserver2005 express失败
- 为什么插入数据总是失败??
- 真的有点不解
- 一个变态的XML,怎么生成DataTable,GOOGLE了一天做不出。郁闷
- Asp.Net生成静态页面[使用ajax ViewState]
- 怎么用WebRequest提交数据到已经是登录状态的网站上?
- 借宝地一用:D,北京,寻找.net和j2me开发高手加盟
- 请教大家如何学习.net网络开发
- 靠!最平常的update语句,却提示我错误!什么叫“异常详细信息”!微软这是什么破吊东西!异常详细信息: System.FormatException: 输入字
- 一个非常不好处理,但是有不得不解决的问题!!!
- 关于 web service
想怎样都可以!
before you bind the datatable to the datagrid, add an additional column:DataTable1.Columns.Add("newkey",typeof(string), "字段1 + '#' + 字段2");then doDataGrid1.DataKeyField = "newkey";
...then you can dostring s = DataGrid1.DataKeys[nItemIndex];
string[] sKeys = s.Split('#');
....
SelectedIndexChanged 事件:在两次服务器发送之间,在数据列表控件中选择了不同的项时发生。 private void DataGrid1_SelectedIndexChanged(object sender, System.EventArgs e)
{
DataView dv;
DataRowView drv;
int index;
string key1, key2; DataGrid1.DataBind(); index = DataGridQuestions.SelectedItem.DataSetIndex; dv = (DataView) DataGridQuestions.DataSource;
drv = dv[index]; key1 = drv["字段1"].ToString();
key2 = drv["字段2"].ToString(); …… }
{
DataView dv;
DataRowView drv;
int index;
string key1, key2; DataGrid1.DataBind(); index = DataGrid1.SelectedItem.DataSetIndex; dv = (DataView) DataGrid1.DataSource;
drv = dv[index]; key1 = drv["字段1"].ToString();
key2 = drv["字段2"].ToString(); …… }