再线等关于datagrid数据绑定的问题 情况是这样的:在用DATAGRID的时候,窗体能显示表的列名,但不能显示里面 的数据 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 1.表里就没有数据2.只设置了Head Text,没有设置Data Field datafield设置了没设置好了直接绑定,只要表里有就应该显示的 <asp:BoundColumn DataField="content" HeaderText="内容" Visible="true"> <HeaderStyle HorizontalAlign="Center" Width="10%"></HeaderStyle> <ItemStyle Wrap="False" HorizontalAlign="right" Width="10%"></ItemStyle></asp:BoundColumn>DataField 的值要与数据库字段值一致 贴一段你的aspx页面里的datagrid的代码出来看看。 datafiled也设置了运行的时候页面一片空白 不好意思我的意思是只通过数据控件来实现小弟在这里说SORRY了 在page_load()里做了处理吗?Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load If Not IsPostBack Then Me.SqlDataAdapter1.Fill(DataSet11) Me.DataGrid1.DataBind() End If End Sub 在属性生成器里看看吧还有,是不是你的 data source没有绑定? 有没有设置datafield?page_load()有没有databind?最好还是把源码贴出来 做了我是用C#的sqlDataAdapter1.Fill(dataSet41,"FJ_FileInfo"); this.DataBind(); private void InitializeComponent() { this.sqlConnection1 = new System.Data.SqlClient.SqlConnection(); this.sqlInsertCommand1 = new System.Data.SqlClient.SqlCommand(); this.sqlUpdateCommand1 = new System.Data.SqlClient.SqlCommand(); this.sqlDeleteCommand1 = new System.Data.SqlClient.SqlCommand(); this.sqlDataAdapter1 = new System.Data.SqlClient.SqlDataAdapter(); this.sqlSelectCommand1 = new System.Data.SqlClient.SqlCommand(); this.dataSet41 = new WebApplication1.DataSet4(); ((System.ComponentModel.ISupportInitialize)(this.dataSet41)).BeginInit(); this.DataGrid1.Unload += new System.EventHandler(this.DataGrid1_Unload); this.DataGrid1.Init += new System.EventHandler(this.DataGrid1_Unload); this.DataGrid1.Disposed += new System.EventHandler(this.DataGrid1_Unload); this.DataGrid1.PreRender += new System.EventHandler(this.DataGrid1_Unload); this.DataGrid1.DataBinding += new System.EventHandler(this.Page_Load); this.DataGrid1.Load += new System.EventHandler(this.DataGrid1_Unload); this.DataGrid1.SelectedIndexChanged += new System.EventHandler(this.DataGrid1_Unload); // // sqlConnection1 // this.sqlConnection1.ConnectionString = "initial catalog=EHR;packet size=4096;integrated security=SSPI;data source=C184;pe" + "rsist security info=False;connect timeout=30;workstation id=C184"; this.sqlConnection1.InfoMessage += new System.Data.SqlClient.SqlInfoMessageEventHandler(this.sqlConnection1_InfoMessage); // sqlInsertCommand1 // this.sqlInsertCommand1.CommandText = @"INSERT INTO FJ_FileInfo(Typeid, title, Authorizer, valid, EnactDate, EnactOrg, ActDate, InvalidDate, ContentType, DocNO, keywords, text, Notes, ClassNo) VALUES (@Typeid, @title, @Authorizer, @valid, @EnactDate, @EnactOrg, @ActDate, @InvalidDate, @ContentType, @DocNO, @keywords, @text, @Notes, @ClassNo); SELECT id, Typeid, title, Authorizer, valid, EnactDate, EnactOrg, ActDate, InvalidDate, ContentType, DocNO, keywords, text, Notes, ClassNo FROM FJ_FileInfo WHERE (id = @@IDENTITY)"; this.sqlInsertCommand1.Connection = this.sqlConnection1; this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Typeid", System.Data.SqlDbType.VarChar, 15, "Typeid")); this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@title", System.Data.SqlDbType.VarChar, 400, "title")); this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Authorizer", System.Data.SqlDbType.VarChar, 10, "Authorizer")); this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@valid", System.Data.SqlDbType.Bit, 1, "valid")); this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@EnactDate", System.Data.SqlDbType.VarChar, 10, "EnactDate")); this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@EnactOrg", System.Data.SqlDbType.VarChar, 400, "EnactOrg")); this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@ActDate", System.Data.SqlDbType.VarChar, 10, "ActDate")); this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@InvalidDate", System.Data.SqlDbType.VarChar, 10, "InvalidDate")); this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@ContentType", System.Data.SqlDbType.VarChar, 200, "ContentType")); this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@DocNO", System.Data.SqlDbType.VarChar, 200, "DocNO")); this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@keywords", System.Data.SqlDbType.VarChar, 2147483647, "keywords")); this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@text", System.Data.SqlDbType.NVarChar, 1073741823, "text")); this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Notes", System.Data.SqlDbType.VarChar, 2147483647, "Notes")); this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@ClassNo", System.Data.SqlDbType.VarChar, 40, "ClassNo")); 怎样在页面关闭时清除cookie啊 .NET中两个窗体的传值问题? JavaScript 的小问题? 求一正则表达式 一个小问题,关于在网页上写内容 关于ACCESS的错误 好多人说ActiveReport比水晶报表好,可是怎么显示柱状图啊? 在SERVER2008的服务器上部署出现的问题 使用asp.net生成静态页面,出现乱码文件 页面中要提交的文本框是不是有一定的限制,如果有600个怎么就不能提交了呢? ♀如何将Web窗体进行扩展后,然后在工程中使用呢?♂Eager 问题来了,哪位能帮解决?(关于连接的)
2.只设置了Head Text,没有设置Data Field
<HeaderStyle HorizontalAlign="Center" Width="10%"></HeaderStyle>
<ItemStyle Wrap="False" HorizontalAlign="right" Width="10%"></ItemStyle>
</asp:BoundColumn>DataField 的值要与数据库字段值一致
运行的时候页面一片空白
我的意思是只通过数据控件来实现
小弟在这里说SORRY了
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
Me.SqlDataAdapter1.Fill(DataSet11)
Me.DataGrid1.DataBind()
End If
End Sub
还有,是不是你的 data source没有绑定?
最好还是把源码贴出来
我是用C#的
sqlDataAdapter1.Fill(dataSet41,"FJ_FileInfo");
this.DataBind();
{
this.sqlConnection1 = new System.Data.SqlClient.SqlConnection();
this.sqlInsertCommand1 = new System.Data.SqlClient.SqlCommand();
this.sqlUpdateCommand1 = new System.Data.SqlClient.SqlCommand();
this.sqlDeleteCommand1 = new System.Data.SqlClient.SqlCommand();
this.sqlDataAdapter1 = new System.Data.SqlClient.SqlDataAdapter();
this.sqlSelectCommand1 = new System.Data.SqlClient.SqlCommand();
this.dataSet41 = new WebApplication1.DataSet4();
((System.ComponentModel.ISupportInitialize)(this.dataSet41)).BeginInit();
this.DataGrid1.Unload += new System.EventHandler(this.DataGrid1_Unload);
this.DataGrid1.Init += new System.EventHandler(this.DataGrid1_Unload);
this.DataGrid1.Disposed += new System.EventHandler(this.DataGrid1_Unload);
this.DataGrid1.PreRender += new System.EventHandler(this.DataGrid1_Unload);
this.DataGrid1.DataBinding += new System.EventHandler(this.Page_Load);
this.DataGrid1.Load += new System.EventHandler(this.DataGrid1_Unload);
this.DataGrid1.SelectedIndexChanged += new System.EventHandler(this.DataGrid1_Unload);
//
// sqlConnection1
//
this.sqlConnection1.ConnectionString = "initial catalog=EHR;packet size=4096;integrated security=SSPI;data source=C184;pe" +
"rsist security info=False;connect timeout=30;workstation id=C184";
this.sqlConnection1.InfoMessage += new System.Data.SqlClient.SqlInfoMessageEventHandler(this.sqlConnection1_InfoMessage);
//
this.sqlInsertCommand1.CommandText = @"INSERT INTO FJ_FileInfo(Typeid, title, Authorizer, valid, EnactDate, EnactOrg, ActDate, InvalidDate, ContentType, DocNO, keywords, text, Notes, ClassNo) VALUES (@Typeid, @title, @Authorizer, @valid, @EnactDate, @EnactOrg, @ActDate, @InvalidDate, @ContentType, @DocNO, @keywords, @text, @Notes, @ClassNo); SELECT id, Typeid, title, Authorizer, valid, EnactDate, EnactOrg, ActDate, InvalidDate, ContentType, DocNO, keywords, text, Notes, ClassNo FROM FJ_FileInfo WHERE (id = @@IDENTITY)";
this.sqlInsertCommand1.Connection = this.sqlConnection1;
this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Typeid", System.Data.SqlDbType.VarChar, 15, "Typeid"));
this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@title", System.Data.SqlDbType.VarChar, 400, "title"));
this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Authorizer", System.Data.SqlDbType.VarChar, 10, "Authorizer"));
this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@valid", System.Data.SqlDbType.Bit, 1, "valid"));
this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@EnactDate", System.Data.SqlDbType.VarChar, 10, "EnactDate"));
this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@EnactOrg", System.Data.SqlDbType.VarChar, 400, "EnactOrg"));
this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@ActDate", System.Data.SqlDbType.VarChar, 10, "ActDate"));
this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@InvalidDate", System.Data.SqlDbType.VarChar, 10, "InvalidDate"));
this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@ContentType", System.Data.SqlDbType.VarChar, 200, "ContentType"));
this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@DocNO", System.Data.SqlDbType.VarChar, 200, "DocNO"));
this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@keywords", System.Data.SqlDbType.VarChar, 2147483647, "keywords"));
this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@text", System.Data.SqlDbType.NVarChar, 1073741823, "text"));
this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Notes", System.Data.SqlDbType.VarChar, 2147483647, "Notes"));
this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@ClassNo", System.Data.SqlDbType.VarChar, 40, "ClassNo"));