如何在ASP.NET中绑定gridview中的数据 [英] How to bind data in gridview in ASP.NET
本文介绍了如何在ASP.NET中绑定gridview中的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在数据库中有一个表,我不知道该表的确切列。我想在页面上使用动态创建的行显示该表格
我尝试过:
< asp:Panel ID =pnltestrunat =server>
员工代码 | 名称 |
787 | iuio |
899 | kjhkj |
i have a table in database and i dont know the exact columns of that table. i want to display that table on page using dynamically creted rows
What I have tried:
<asp:Panel ID="pnltest" runat="server">
Employee Code | Name |
787 | iuio |
899 | kjhkj |
推荐答案
创建gridview并设置<$的属性c $ c> AutoGenerateColumns =true
并将数据表绑定到它。
Create a gridview and set the property ofAutoGenerateColumns="true"
and bind the datatable to it.
<asp:GridView runat="server" ID="gridViewName" AutoGenerateColumns="true"></asp:GridView>
gridViewName.DataSource = yourDataTable;
gridViewName.DataBind();
您好,请参阅以下链接,
1.
Hi, refer below links,
1.
Control.DataBind Method ()
[ ^ ]
2. GridView.DataBind方法(System.Web.UI.WebControls) [ ^ ]
这篇关于如何在ASP.NET中绑定gridview中的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文