I'm trying to create my first web form app and trying to use the checkbox is giving me issues. i want the submit button to deduct from my database and ive already done the checkbox
private void BindGrid()
{
try
{
SqlConnection con = new SqlConnection("Data Source=W-IT004\\MSSQLSERVER2012;Initial Catalog=MyDatabase;User ID=sa;Password=qwerty;Pooling=False");
con.Open();
SqlCommand cmd = new SqlCommand("Select [Title], [Duration], [OldBorrowPrice] ,[Damage Price] from Movie", con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt);
GridView1.DataSource = dt;
GridView1.DataBind();
con.Close();
da.Dispose();
}
catch (Exception ex )
{
string exx = ex.Message;
}
}
protected void BorrowButton_Click(object sender, EventArgs e)
{
}
答案 0 :(得分:1)
Here you have DataTable dt=new DataTable();
Try to use
DataSet ds=new DataSet();
da.Fill(ds);
GridView1.DataSource=ds;
GridView1.DataBind();
I hope it will work