使用动态列和动态行动态绑定gridview并在gridview中进行编辑和更新?

时间:2011-09-30 07:03:59

标签: c# gridview asp.net-ajax aspxgridview jqgrid-asp.net

我是.net应用程序开发的新手。请帮我找到解决方案。 我的要求是我从数据库中获取填充数据表。现在我想在GridView中填充它。问题是列名和列数根据Dropdownlist中的选定值进行了更改,并且DataTable根据所选值填充在Dropdownlist.Now我想动态生成GridView的列和行,并且还想编辑和更新创建的行。列和行的数量不固定它根据Dropdawnlist中所选的预测而变化。所以请帮助我解决问题。

提前致谢

1 个答案:

答案 0 :(得分:1)

实际上GridView控件具有自动生成列的功能。

查看有关ASP.NET中数据访问的初学者:http://www.asp.net/data-access/tutorials

用两个词来说:

<asp:sqldatasource id="CustomersSource"
  selectcommand="SELECT CustomerID, CompanyName, FirstName, LastName FROM SalesLT.Customer"
  connectionstring="<%$ ConnectionStrings:AWLTConnectionString %>" 
  runat="server"/>

<asp:gridview id="CustomersGridView" datasourceid="CustomersSource" autogeneratecolumns="True" 
  runat="server">        
</asp:gridview>
相关问题