我是用一个DataGrid空间绑定了一个超级连接列,绑定的是cnat_id然后提交到另一个页面去修改!也就是提交到添加的页面去修改让数据显示在TextBox中,数据库一共11个字段。DBCon是一个链接类,数据库主键字段也叫cnat_id下一步改怎么弄呀才能让数据显示在TextBox中
string cnat_id=Request.QueryString["cnat_id"].ToString();
SqlConnection con=DBCon.createCon();
SqlCommand cnd=new SqlCommand("select jgsj from cnatword where cnat_id=cnat_id",con);
string cnat_id=Request.QueryString["cnat_id"].ToString();
SqlConnection con=DBCon.createCon();
SqlCommand cnd=new SqlCommand("select jgsj from cnatword where cnat_id=cnat_id",con);
SqlDataAdapter sda = new SqlDataAdapter(("select jgsj from cnatword where cnat_id=cnat_id",con);
DataTable dt = new DataTable;
sda.Fill(dt);
TextBox.Text = dt.rows[行数][列数].tostring();
DataSet ds=new DataSet();
ds.Fill(sda);
this.TextBox1.Text=ds.Tables[0]["你的字段"].ToString();
行数列数指的是什么?我新手不太明白!!也比较笨!
("select jgsj from cnatword where cnat_id=cnat_id",con);但是我把字段名称写进去运行的时候它说我
C:\Inetpub\wwwroot\cnat_work\index.aspx.cs(75): 名称“jgsj”在类或命名空间“cnat_work.index”中不存在
着是怎么了?
("select jgsj from cnatword where cnat_id='"+cnat_id+"'",con);
如果是单选按妞着句该怎么写呢!????
this.cnat_x1.Checked=dt.Rows[2]["sfzp"].ToString();
这句该怎么写?????
if(!IsPostBack)
{
this.cnat_x1.autopostback = true;
}
然后在单选择按钮的事件中把值赋给文本框就行了
我的意思是说我的小例子比方说!就一个单选择按钮 是的话就选择 不是的话就不选择 我在添加的时候是这样判断的写如数据库的
if(this.cnat_x1.Checked)
{
p.cnat_x1="是";
}
else
{
p.cnat_x1="";
}
修改的时候!得显示选中状态!
if(dt.Rows[2]["sfzp"].ToString().Equals("是")
{
this.cnat_x1.Checked = true;
}
else
{
this.cnat_x1.Checked = false;
}
{
this.cnat_x2.Checked = true;
}
else
{
this.cnat_x2.Checked = false;
} if(dt.Rows[23]["ywpj"].ToString().Equals("良"))
{
this.cnat_x3.Checked = true;
}
else
{
this.cnat_x3.Checked = false;
}
if(dt.Rows[24]["ywpj"].ToString().Equals("差"))
{
this.cnat_x4.Checked = true;
}
else
{
this.cnat_x4.Checked = false;
}
如果是评价优良差呢!我该怎么判断吗?但是显示错误呀!
if(this.cnat_x2.Checked)
{
p.pj="优";
}
if(this.cnat_x3.Checked)
{
p.pj="良";
}
if(this.cnat_x4.Checked)
{
p.pj="差";
}
不用Equals,用if(dt.Rows[24]["ywpj"].ToString()=="差")
第零列
但是我有很多数据显示的都是第零的!改怎么办?
我数据库中有很多行数据!现在都显示的是第0行的数据!我怎么才能让他按照这个传进去的数据库的主键显示正确的行数里的数据呢?
string cnat_id=Request.QueryString["cnat_id"].ToString();
比方说我着个例子要上传网上!在网上添加数据然后写入数据库!我想让我的DataGrid绑定的超级连接列点进去之后按照数据库中的主键查找相对的数据写入相对TEXTBOX中!~
行号我改怎么写才能按照我提交出去的主键查找到呢!