using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SQLite;public partial class pAntiCounterfeit_Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{ }
protected void Button1_Click(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.TextBox1.Text = "123";
SQLiteConnection cnn = new SQLiteConnection();
cnn.ConnectionString = @"Data Source=D:\CBFJ\CBFJ_www\App_Data\AppData.db";
cnn.Open(); SQLiteCommand cmd = new SQLiteCommand();
cmd.Connection = cnn; cmd.CommandText = "select * from counterfeitdtl";
SQLiteDataAdapter da = new SQLiteDataAdapter();
da.SelectCommand = cmd;
DataSet ds = new DataSet();
da.Fill(ds);
DataTable dt = ds.Tables["counterfeitdtl"];
this.GridView1.DataSource =dt;
this.GridView1.DataBind();
cnn.Close();
}
}
}代码如上,在WINFORM中我用DATAGRIDVIEW测试通过。
但是换成.net就不行了。gridview什么也不显示。郁闷了。
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SQLite;public partial class pAntiCounterfeit_Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{ }
protected void Button1_Click(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.TextBox1.Text = "123";
SQLiteConnection cnn = new SQLiteConnection();
cnn.ConnectionString = @"Data Source=D:\CBFJ\CBFJ_www\App_Data\AppData.db";
cnn.Open(); SQLiteCommand cmd = new SQLiteCommand();
cmd.Connection = cnn; cmd.CommandText = "select * from counterfeitdtl";
SQLiteDataAdapter da = new SQLiteDataAdapter();
da.SelectCommand = cmd;
DataSet ds = new DataSet();
da.Fill(ds);
DataTable dt = ds.Tables["counterfeitdtl"];
this.GridView1.DataSource =dt;
this.GridView1.DataBind();
cnn.Close();
}
}
}代码如上,在WINFORM中我用DATAGRIDVIEW测试通过。
但是换成.net就不行了。gridview什么也不显示。郁闷了。
把!去掉,改成:
if (IsPostBack)
{
..........
}
{
if (!IsPostBack)
{BindData();} }
private void BindData()
{}
DataSet ds = new DataSet();
this.GridView1.DataSource =ds;
this.GridView1.DataBind();
cnn.Close(); 试试,不知道行不
<asp:BoundField />
<asp:BoundField DataField="hdate" HeaderText="hdate" SortExpression="111" />
必须写boundfield。
。NET
我草