insert into数据库里面没有数据,请帮忙看看。
protected void Button2_Click(object sender, EventArgs e)
{ for (int i = 0; i < this.GridView1.Rows.Count; i++)
{
string value1 = (this.GridView1.Rows[i].FindControl("TextBox1") as TextBox).Text.Trim();
string value2 = (this.GridView1.Rows[i].FindControl("TextBox2") as TextBox).Text.Trim();
string value3 = (this.GridView1.Rows[i].FindControl("TextBox3") as TextBox).Text.Trim();
string value4 = (this.GridView1.Rows[i].FindControl("TextBox4") as TextBox).Text.Trim(); RadioButton rb = GridView1.Rows[i].FindControl("RadioButton1") as RadioButton;
if (rb.Checked)
{
string str2 = "是";
}
else
{
string str2 = "否";
}
DropDownList ddl = GridView1.Rows[i].FindControl("DropDownList1") as DropDownList;
if (ddl.SelectedValue != "")
{ string str2 = ddl.SelectedValue;
} SqlConnection conn = zong.createcon();
conn.Open();
string sql = "insert into qqyy values xm='" + value1 + "',gh='" + value2 + "',jz='" + value3 + "',lb='" + value4 + "','"+rb+"','"+ddl+"'";
SqlCommand cmd = new SqlCommand(sql, conn);
cmd.ExecuteNonQuery();
conn.Close();
}
protected void Button2_Click(object sender, EventArgs e)
{ for (int i = 0; i < this.GridView1.Rows.Count; i++)
{
string value1 = (this.GridView1.Rows[i].FindControl("TextBox1") as TextBox).Text.Trim();
string value2 = (this.GridView1.Rows[i].FindControl("TextBox2") as TextBox).Text.Trim();
string value3 = (this.GridView1.Rows[i].FindControl("TextBox3") as TextBox).Text.Trim();
string value4 = (this.GridView1.Rows[i].FindControl("TextBox4") as TextBox).Text.Trim(); RadioButton rb = GridView1.Rows[i].FindControl("RadioButton1") as RadioButton;
if (rb.Checked)
{
string str2 = "是";
}
else
{
string str2 = "否";
}
DropDownList ddl = GridView1.Rows[i].FindControl("DropDownList1") as DropDownList;
if (ddl.SelectedValue != "")
{ string str2 = ddl.SelectedValue;
} SqlConnection conn = zong.createcon();
conn.Open();
string sql = "insert into qqyy values xm='" + value1 + "',gh='" + value2 + "',jz='" + value3 + "',lb='" + value4 + "','"+rb+"','"+ddl+"'";
SqlCommand cmd = new SqlCommand(sql, conn);
cmd.ExecuteNonQuery();
conn.Close();
}
解决方案 »
- 在web页面调用exe,上一帖未解决
- <script src="xxxxx"> src到底是个什么概念,为什么可以是js文件,asp文件,甚至exe文件
- 克隆2003系统到一个新硬盘,无法登录进入系统,一登录便退出,要怎么办才好???
- 帮忙看看一个简单的框架中页面的传值问题
- 为什么用DataTable填充DataGrid时会出现乱码?
- 小弟求问一个菜鸟问题
- DropDownList1数据显示问题
- Crystal Reports 9 最新补丁下载(搜集:海波.NET)
- 牛人测试网站
- 帮我看看,搞了半天也没搞定,累的兄弟满头汗
- asp控件onclick调用的方法在对应的CodeBehind文件中已经有了,可是运行的时候为什么还提示说方法不存在?
- LENGTEMP这是什么意思呢?
是控件
要是加的话要if (rb.Checked)
{
string rbstr = "是";
}
else
{
string rbstr = "否";
}
DropDownList ddl = GridView1.Rows[i].FindControl("DropDownList1") as DropDownList;
if (ddl.SelectedValue != "")
{ string ddlstr= ddl.SelectedValue;
}
rb换成rbstr
ddl换成ddlstr
string value1 = (this.GridView1.Rows[i].FindControl("TextBox1") as TextBox).Text.Trim();
我现在需要把上面的几个插入到另外的表中。
那string value1 = (this.GridView1.Rows[i].FindControl("Label1") as Label).Text.Trim();
这样是不是正确的?
我现在需要把上面的几个插入到另外的表中。
那string value1 = (this.GridView1.Rows[i].FindControl("Label1") as Label).Text.Trim();
这样是不是正确的?
我现在需要把上面的几个插入到另外的表中。
那string value1 = (this.GridView1.Rows[i].FindControl("Label1") as Label).Text.Trim();
我转成了模板,这样是不是正确的?