缺少
DataView Source = ds.Tables["customers"].DefaultView;
mydatagrid.datasource=Source;
DataView Source = ds.Tables["customers"].DefaultView;
mydatagrid.datasource=Source;
解决方案 »
- 一个sql语句引发的血案?????????????????????????真的没有分了
- 如何修改App_GlobalResources 中Resource.resx的内容?
- 关于数据访问层的困惑!
- 一个关于datagrid超级链接列传递值的问题,谢谢。
- 多条件查询的问题,以前问过,但现在查询不到以前的文章~
- 求救,为什么显示的不是我选中那行的数据值?
- 各位高手请教一个传递参数的问题(初学者请教个很菜的问题)谢谢!
- 想换c#程序学习的大侠进来看看!
- 如果解决VS中自动产生的自定义控件模板?
- 关于excel程序日期格式问题
- DropDownList的SelectedIndexChanged事件为何不触发?
- 这段代码究竟错在哪?怪了!!!
我写的是c#的
vb的要这么写
DataView Source = ds.Tables("customers").DefaultView
mydatagrid.datasource=Source
<%@ Import Namespace="System.Data.SqlClient" %><html>
<script language="C#" runat="server"> SqlConnection myConnection; protected void Page_Load(Object sender, EventArgs e)
{
myConnection =new SqlConnection("data source=你的ip;user id=sa;password=;initial catalog=pubs"); if (!IsPostBack)
BindGrid("au_id");
} protected void MyDataGrid_Sort(Object sender, DataGridSortCommandEventArgs e)
{
BindGrid(e.SortExpression);
} public void BindGrid(String sortfield)
{
SqlDataAdapter myCommand = new SqlDataAdapter("select * from Authors", myConnection); DataSet ds = new DataSet();
myCommand.Fill(ds, "Authors"); DataView Source = ds.Tables["Authors"].DefaultView;
Source.Sort = sortfield; MyDataGrid.DataSource=Source;
MyDataGrid.DataBind();
}</script><body> <h3><font face="Verdana">Sorting Data in a DataGrid Control</font></h3> <form runat="server"> <ASP:DataGrid id="MyDataGrid" runat="server" OnSortCommand="MyDataGrid_Sort"
Width="700"
BackColor="#ccccff"
BorderColor="black"
ShowFooter="false"
CellPadding=3
CellSpacing="0"
Font-Name="Verdana"
Font-Size="8pt"
HeaderStyle-BackColor="#aaaadd"
AllowSorting="true"
/> </form></body>
</html>
在sql server上用
在"你的ip"出改为你自己的ip 要是本机的sql server可以写localhost
user 为用户名
password是密码这样就可以运行了