是要写事件的
private void DataGrid1_PageIndexChanged(object source, System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
{
DataGrid1.CurrentPageIndex = e.NewPageIndex;
}
private void DataGrid1_PageIndexChanged(object source, System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
{
DataGrid1.CurrentPageIndex = e.NewPageIndex;
}
不行阿,还是只有文字,没有链接。
我是绑定Table,和DataSet应该是一样的
然后事件里PageIndexChanged加上事件,代码象刚才所写,
但不知道对你是否适用
另把那个AllowCustomPaging =True 改成false试一下
确实取到了这么多记录,
用table怎么绑定阿?
给个实例阿
SqlConnection myConnection = new SqlConnection(ConfigurationSettings.AppSettings["你的打开方式"]);
SqlDataAdapter wAdapter = new SqlDataAdapter();myConnection.Open();
SqlCommand wCommand = new SqlCommand(SearchString, myConnection);
wCommand.CommandType = CommandType.Text;
wAdapter.SelectCommand = wCommand;
// Create and Fill the DataSet
wAdapter.Fill(table);
myConnection.Close();
//前面是取数据的DataGrid1.DataSource = table;
DataGrid1.DataBind();
Dim ds As New DataSet()
myad.Fill(ds, "t001")
DataGrid1.DataSource = ds.table("t001").faultview
DataGrid1.DataBind()
我改成40 就只显示40条,改成10就只显示10条,
上一页和下一页都没有链接。如果把 AllowCustomPaging =True 去掉就会出错
类型“DataGridLinkButton”的控件“Grid__ctl14__ctl1”必须放在具有 runat=server 的窗体标记内。 <asp:DataGrid AllowPaging="True" PageSize="10" PagerStyle-PrevPageText='上一页' PagerStyle-NextPageText='下一页' id="Grid" Width="100%" runat="server" BorderColor="#CCCCCC" ItemStyle-Height="30" AlternatingItemStyle-BackColor="#f2f2f2" HeaderStyle-BackColor="#f7f7f7" ShowFooter="True" OnPageIndexChanged ="Grid_PageIndexChanged">
这样写有什么问题吗??
LinkButton来取数据,可以参考一下这个
http://www.csdn.net/Expert/TopicView1.asp?id=964969
这个比较简单
只能是自定义分页 即:
AllowCustomPaging =True 做自定义分页一定要设置
VirtualItemCount 属性为你的数据表的纪录数
DataGrid 才知道你有多少页
只能是自定义分页 即:
AllowCustomPaging =True 做自定义分页一定要设置
VirtualItemCount 属性为你的数据表的纪录数
DataGrid 才知道你有多少页
但是如果把 AllowCustomPaging =True 去掉就会出错
类型“DataGridLinkButton”的控件“Grid__ctl14__ctl1”必须放在具有 runat=server 的窗体标记内。 comm.CommandText ="Select * From bbs order by pubtime desc";
OleDbDataAdapter adapter=new OleDbDataAdapter ();
adapter.SelectCommand =comm;
DataTable table = new DataTable();
adapter.Fill(table);
conn.Close();
Grid.DataSource =table;
Grid.DataBind ();<asp:DataGrid id="Grid" AllowPaging =True PageSize = 20 runat="server" PagerStyle-PrevPageText='上一页' PagerStyle-NextPageText='下一页' >
</asp:DataGrid>这样写有什么问题阿?还少什么?出现提示错误
类型“DataGridLinkButton”的控件“Grid__ctl24__ctl1”必须放在具有 runat=server 的窗体标记内。
但是提示 类型“DataGridLinkButton”的控件“Grid__ctl9__ctl1”必须放在具有 runat=server 的窗体标记内莫名其妙阿
</form>解决了,原来要放在form里面阿,大家都有分。