GridView.Rows[0].Cells[1].Text,取不到自动增长列的值 这1列数据库为 identity现在取出来值都是“”,大家有没有碰到过?怎么解决? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 this.dataGridView1.Rows[0].Cells[0].Value.ToString();int.Parsse(this.dataGridView1.Rows[0].Cells[0].Value.ToString()); this.dataGridView1.Rows[0].Cells[1].Value.ToString(); 我的是GridView1,asp,没有value这个属性 Tabale 的 值 为空?dataGridView1.Rows[0].Cells[1].ValuedataGridView1.Rows[0][1].tostring()或dataGridView1.Rows[0][“字段名”].tostring() if(IsPostBack){ } 控件 obj = this.dataGridView1.Rows[0].FindControl as 控件obj.属性 你看下生成出来的事什么 this.dataGridView1.Rows[0].Cells[0].Value.ToString(); 我是先load中给gridveiw绑定数据if (!Page.IsPostBack) { loaddata(); }然后GridView1_RowCommand()中取值,其他什么都没做若不是 自增长列,这个方法没问题呀,就ID取不到 this.dataGridView1.Rows[0].Cells[0].Text.ToString(); protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "lnk_edit") { int index = Convert.ToInt32(e.CommandArgument); string strid = GridView1.Rows[index].Cells[0].Text.ToString(); string strname = GridView1.Rows[index].Cells[2].Text.ToString(); }} void GridView1_RowCreated(object sender, GridViewRowEventArgs e){ //让索引为0的列不可见,实际上是产生的css代码 e.Row.Cells[0].Visible = false; //other code if neccecary}最后发现是隐藏列的问题,与数据库无关,加上这个方法就可以了,谢谢大家啊 TableCell cell = drplist.Parent as TableCell; var row = cell.Parent as GridViewRow; int rownum = row.RowIndex; string str = spgridview.Rows [rownum].Cells [0].Text 访问局域网共享文件夹 这个的错误提示需要安装什么版本的水晶报表? 基础类和关键字的区别 万能的牛人们~~C#里面如何进行键盘控制?? 读取相对路径问题??????C# 文件操作的一个小问题 !!!!!!老是提示不能删除! 急急急,DataGrid中模板列绑入一 Button按钮,现怎样做到点击此按钮可选中本行,且又可引发一个OnClick事件呢!!! 还是不懂!!!!!!!! C#中如何将一个Excel文件的多个表分解成单独的几个文件 string.Format输出格式问题 winform实现可编辑模板打印 C#反编译
int.Parsse(this.dataGridView1.Rows[0].Cells[0].Value.ToString());
dataGridView1.Rows[0].Cells[1].ValuedataGridView1.Rows[0][1].tostring()或dataGridView1.Rows[0][“字段名”].tostring()
{
}
obj.属性
你看下生成出来的事什么
if (!Page.IsPostBack)
{
loaddata();
}
然后GridView1_RowCommand()
中取值,其他什么都没做若不是 自增长列,这个方法没问题呀,就ID取不到
{
if (e.CommandName == "lnk_edit")
{
int index = Convert.ToInt32(e.CommandArgument); string strid = GridView1.Rows[index].Cells[0].Text.ToString();
string strname = GridView1.Rows[index].Cells[2].Text.ToString();
}
}
{
//让索引为0的列不可见,实际上是产生的css代码
e.Row.Cells[0].Visible = false;
//other code if neccecary
}最后发现是隐藏列的问题,与数据库无关,加上这个方法就可以了,谢谢大家啊
var row = cell.Parent as GridViewRow;
int rownum = row.RowIndex;
string str = spgridview.Rows [rownum].Cells [0].Text