GridView view = sender as GridView

G13402045 2010-09-16 11:03:31
GridView view = sender as GridView这句话用VB.NET怎么写啊
...全文
88 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
兔子-顾问 2010-09-16
  • 打赏
  • 举报
回复
http://www.developerfusion.com/tools/convert/csharp-to-vb/
兔子-顾问 2010-09-16
  • 打赏
  • 举报
回复
Dim view As GridView = CType(sender,GridView)
using System; using System.Data; using System.Data.SqlClient; using System.Configuration; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { LoginAcc.LoginCheck(); if (!Page.IsPostBack) { DataBind(); } } void DataBind() { //string str = "select NewsId,Title,AddTime,ViewCounter from ViewTable order by AddTime desc"; SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString); conn.Open(); SqlCommand cmd = new SqlCommand("up_GetDetilNews", conn); cmd.CommandType = CommandType.StoredProcedure; DataSet ds = new DataSet(); SqlDataAdapter da = new SqlDataAdapter(cmd); da.Fill(ds,"result"); GridView1.DataSource = ds.Tables["result"]; GridView1.DataBind(); } protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e) { //GridView1.PageIndex = e.NewPageIndex; GridView theGrid = sender as GridView; // refer to the GridView int newPageIndex = 0; if (-2 == e.NewPageIndex) { // when click the "GO" Button TextBox txtNewPageIndex = null; //GridViewRow pagerRow = theGrid.Controls[0].Controls[theGrid.Controls[0].Controls.Count - 1] as GridViewRow; // refer to PagerTemplate GridViewRow pagerRow = theGrid.BottomPagerRow; //GridView较DataGrid提供了更多的API,获取分页块可以使用BottomPagerRow 或者TopPagerRow,当然还增加了HeaderRow和FooterRow //updated at 2006年6月21日3:15:33 if (null != pagerRow) { txtNewPageIndex = pagerRow.FindControl("txtNewPageIndex") as TextBox; // refer to the TextBox with the NewPageIndex value } if (null != txtNewPageIndex) { newPageIndex = int.Parse(txtNewPageIndex.Text) - 1; // get the NewPageIndex } } else { // when click the first, last, previous and next Button newPageIndex = e.NewPageIndex; } // check to prevent form the NewPageIndex out of the range newPageIndex = newPageIndex < 0 ? 0 : newPageIndex; newPageIndex = newPageIndex >= theGrid.PageCount ? theGrid.PageCount - 1 : newPageIndex; // specify the NewPageIndex theGrid.PageIndex = newPageIndex; // rebind the control // in this case of retrieving the data using the xxxDataSoucr control, // just do nothing, because the asp.net engine binds the data automatically // 别忘了重新绑定 DataBind(); } protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) { string strId = (GridView1.DataKeys[e.RowIndex].Value).ToString(); string delStr = "delete from ViewTable where NewsId=" + strId; DbUtil.DbHelper.ExecSqlNonQuerry(delStr); DataBind(); MyUtil.CsHelper.ExecJS("删除成功!", this); } }

16,555

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧