还是不成
朋友们还是不成,各种方法都用了数据库表的ID也是int类型,真不知该怎么办了,不会是设成自动增长标识列造成的吧
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
public partial class addxzflower : System.Web.UI.Page
{
private static string connectionString = "server=.;uid=sa;pwd=1;database=flowershops";
yyjDAL.WebClass cl = new yyjDAL.WebClass();
protected void Page_Load(object sender, EventArgs e)
{
Label1.Text = Session["Username"].ToString();
if (!IsPostBack)
{
GridView1.DataKeyNames = new String[] { "st_name" };
this.GridView1.DataSource = cl.GetAllxx();
this.GridView1.DataBind();
}
if (!IsPostBack)
{
DataTable newdtb = new DataTable();
newdtb.Columns.Add("st_id", typeof(int));
newdtb.Columns.Add("st_name", typeof(string));
newdtb.Columns.Add("ST_Price", typeof(string));
newdtb.Columns.Add("ST_Sales", typeof(string));
newdtb.Columns.Add("ST_Type", typeof(string));
newdtb.Columns["st_name"].AutoIncrement = true;
}
}
protected void Button1_Click(object sender, EventArgs e)
{
DataTable newdtb = new DataTable();
newdtb.Columns.Add("st_name", typeof(string));
newdtb.Columns.Add("ST_Price", typeof(string));
newdtb.Columns.Add("ST_Sales", typeof(string));
newdtb.Columns.Add("ST_Type", typeof(string));
newdtb.Columns["st_name"].AutoIncrement = true;
foreach (GridViewRow item in GridView1.Rows)
{