
不过你也可以在vs2005中使用旧版的datagrid控件,具体做法是在vs2005的左侧工具箱中点击右键,然后选择添加,把datagrid控件添加回来就可以了
VS2005里 用DataGrideView 或 DataGride 都能直接实现插入和删除但是删除的话则有多种方法实现 我只列举几种
1.添加一个删除按钮 在按钮的MouseClick事件中写
2.做一个KeyDonw事件 判断 键盘按下的是否是 Delete 按钮如果是
删除数据
3. 添加右键菜单 也可以
4. 你说的功能 在WinForm里 没有什么有效的方法实现
但是在Asp.Net中 你一行代码都不用写 就能实现
这个问题我不久前才回答过一个朋友的,你怎么不现搜索一下相关内容呀用PagedDataSource对象处理分页,我一直这么做的,在VS2003下的示例代码希望对你有帮助:
//Grid控件的数据绑定
private void DgDataBind()
{
PagedDataSource objPage = new PagedDataSource()
objPage.DataSource = this.dvUsersRecord
objPage.AllowPaging = true
objPage.PageSize = 8
int CurPage
if (Request.QueryString["Page"] != null)
CurPage = Convert.ToInt32(Request.QueryString["Page"])
else CurPage = 0
objPage.CurrentPageIndex = CurPage
if (objPage.PageCount <= 1)
{
hy_Next.Visible = false
hy_Back.Visible = false
}
else
{
string strUrl = Request.RawUrl
if (!objPage.IsFirstPage)
{
hy_Back.Visible = true
if (strUrl.IndexOf('?') == -1)
hy_Back.NavigateUrl = strUrl + "?Page=" + Convert.ToString(CurPage - 1)
else
{
if (strUrl.IndexOf("Page") == -1)
hy_Back.NavigateUrl = strUrl + "&Page=" + Convert.ToString(CurPage - 1)
else
{
string Words = strUrl.Substring(0, strUrl.IndexOf("Page"))
hy_Back.NavigateUrl = Words + "&Page=" + Convert.ToString(CurPage - 1)
}
}
}
if (!objPage.IsLastPage)
{
hy_Next.Visible = true
if (strUrl.IndexOf('?') == -1)
hy_Next.NavigateUrl = strUrl + "?Page=" + Convert.ToString(CurPage + 1)
else
{
if (strUrl.IndexOf("Page") == -1)
hy_Next.NavigateUrl = strUrl + "&Page=" + Convert.ToString(CurPage + 1)
else
{
string Words = strUrl.Substring(0, strUrl.IndexOf("Page"))
hy_Next.NavigateUrl = Words + "&Page=" + Convert.ToString(CurPage + 1)
}
}
}
}
lb_PageMsg.Text = " 当前页:" + (CurPage + 1).ToString() + "/" + objPage.PageCount.ToString()
this.DGUsers.DataSource = objPage
this.DGUsers.DataBind()
}
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)