實現DataGrid 我分頁的多條記錄的選擇....

原创 2005年03月01日 21:24:00

本文參見孟子e章的<<跨頁實現多選>>C#版http://dotnet.aspx.cc/ShowDetail.aspx?id=F43AF9A5-2C2E-4AA6-E976-21E9569F5A8A

下面是我采用vb.net寫的...

前台頁面部分 : DataGrid_1.aspx

<%@ Page Language="vb" AutoEventWireup="false" Codebehind="DataGrid_1.aspx.vb" Inherits="OA.DataGrid_1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
 <HEAD>
  <title>DataGrid_1</title>
  <script language="javascript">
 function AddRemoveValues(oChk)
 {
  if(oChk.checked)
  Form1.HdnSelectedValues.value += "," + oChk.value;
  else
  Form1.HdnSelectedValues.value = Form1.HdnSelectedValues.value.replace("," + oChk.value,"");
 }
  </script>
  <meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
  <meta content="Visual Basic .NET 7.1" name="CODE_LANGUAGE">
  <meta content="JavaScript" name="vs_defaultClientScript">
  <meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
 </HEAD>
 <body MS_POSITIONING="GridLayout">
  <form id="Form1" method="post" runat="server">
   <asp:datagrid id="DataGrid1" AllowPaging="True" Runat="server" Visible="true" Width="600px" AutoGenerateColumns="False"
    HorizontalAlign="Center">
    <AlternatingItemStyle BackColor="#EEEEEE"></AlternatingItemStyle>
    <HeaderStyle BackColor="#AAAADDD" Font-Bold="True" HorizontalAlign="Center"></HeaderStyle>
    <PagerStyle HorizontalAlign="Right" Mode="NumericPages"></PagerStyle>
    <Columns>
     <asp:TemplateColumn HeaderText="選擇">
      <ItemTemplate>
       <input type="checkbox" runat=server id="chkSelect" onclick="AddRemoveValues(this)"
     value='<%#DataBinder.Eval(Container.DataItem,"Title")%>'/>
      </ItemTemplate>
     </asp:TemplateColumn>
     <asp:TemplateColumn HeaderText="文章標題">
      <ItemTemplate>
       <asp:Literal Text='<%#DataBinder.Eval(Container.DataItem,"Title")%>' Runat=server ID="Title_show">
       </asp:Literal>
      </ItemTemplate>
     </asp:TemplateColumn>
     <asp:TemplateColumn HeaderText="發布日期">
      <ItemTemplate>
       <asp:Literal Text='<%#DataBinder.Eval(Container.DataItem,"CreateDate").tostring()%>' Runat=server>
       </asp:Literal>
      </ItemTemplate>
     </asp:TemplateColumn>
    </Columns>
   </asp:datagrid>
   <div align="center"><asp:button id="Button1" runat="server" Text="得到所選的值"></asp:button>
    <div id="Status"><asp:label id="Label1" runat="server"></asp:label></div>
    <INPUT id="HdnSelectedValues" type="hidden" name="HdnSelectedValues" runat="server">
   </div>
  </form>
 </body>
</HTML>


後台代碼部分:DataGrid_1.aspx.vb

Public Class DataGrid_1

   Inherits System.Web.UI.Page

 

 

#Region " Web Form Designer Generated Code "

     'This call is required by the Web Form Designer.

     'This call is required by the Web Form Designer.

    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

     End Sub

     End Sub

    Protected WithEvents DataGrid1 As System.Web.UI.WebControls.DataGrid

    Protected WithEvents Button1 As System.Web.UI.WebControls.Button

    Protected WithEvents Label1 As System.Web.UI.WebControls.Label

    Protected WithEvents HdnSelectedValues As System.Web.UI.HtmlControls.HtmlInputHidden

 

 

    'NOTE: The following placeholder declaration is required by the Web Form Designer.

    'Do not delete or move it.

    Private designerPlaceholderDeclaration As System.Object

 

 

    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init

        'CODEGEN: This method call is required by the Web Form Designer

        'Do not modify it using the code editor.

        InitializeComponent()

        Me.EnableViewState = True

    End Sub

 #End Region

 #End Region

    Private idtb_temp As New DataTable

    Private idtb_temp As New DataTable

    Private idrw_row As DataRow

     Private Sub IntializeDataTable()

     Private Sub IntializeDataTable()

 

 

        For i As Integer = 0 To 60

            idrw_row = idtb_temp.NewRow

            idrw_row.Item("Title") = "AAAA" & i

            idrw_row.Item("CreateDate") = System.DateTime.Now

            idtb_temp.Rows.Add(idrw_row)

        Next

        Me.DataGrid1.DataSource = idtb_temp

        Me.DataGrid1.DataBind()

    End Sub

    End Sub

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        'Put user code to initialize the page here

        If Not Me.Page.IsPostBack Then

            idtb_temp.Columns.Add("Title")

            idtb_temp.Columns.Add("CreateDate")

            IntializeDataTable()

        End If

     End Sub

     End Sub

      Private Sub DataGrid1_PageIndexChanged(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridPageChangedEventArgs) Handles DataGrid1.PageIndexChanged

      Private Sub DataGrid1_PageIndexChanged(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridPageChangedEventArgs) Handles DataGrid1.PageIndexChanged

        Me.DataGrid1.CurrentPageIndex = e.NewPageIndex

        idtb_temp.Columns.Add("Title")

        idtb_temp.Columns.Add("CreateDate")

        IntializeDataTable()

    End Sub

 

 

    Private Sub DataGrid1_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles DataGrid1.ItemDataBound

        If e.Item.ItemType = ListItemType.Item And e.Item.ItemType = ListItemType.AlternatingItem Then

            If Me.HdnSelectedValues.Value.IndexOf(CType(e.Item.Cells(1).FindControl("TitleShow"), Literal).Text) >= 0 Then

                Dim ChkSelected As HtmlInputCheckBox = CType(e.Item.Cells(0).FindControl("chkSelect"), HtmlInputCheckBox)

                ChkSelected.Checked = True

            End If

        End If

    End Sub

 

 

    Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

        Me.Label1.Text = Me.HdnSelectedValues.Value.Replace(",", "<li>")

        Me.Label1.Text = Me.HdnSelectedValues.Value.Replace(",", "<li>")

     End Sub

     End Sub

End Class

 

效果圖:

  DataGrid 記錄的多頁選擇...  

版权声明:本文为博主原创文章,未经博主允许不得转载。

相关文章推荐

datagrid排序_选择_分页

ThinkPHP与EasyUI整合之二(datagrid):删除多条记录

学习EasyUI已有一段时间了,现在开始逐步把平时学习的细节和难点记录下来。 1. datagrid选中多条记录的语句是:   var rows = $('#dg').datagrid('getS...

ssh结合DataGrid 实现分页

  • 2015-12-22 21:22
  • 29.50MB
  • 下载

flex3 对dataGrid 实现分页

  • 2008-09-12 22:04
  • 447KB
  • 下载

EasyUI的datagrid组件实现分页

EasyUI的datagrid组件实现分页,后台为Struts2+Spring+Hibernate,利用DetachedCriteria对象进行简单的分页查询。要点: datagrid组件的参数和响应...

easyui 服务器端与客户端实现分页信息(easyui datagrid serverside and client side paginnation)

//设置分页控件      var p = $('#list_data').datagrid('getPager');      $(p).pagi...

代码分析-DataGrid实现增删(带提示)改和分页

或许大家会说,网上已经很多类似文章了,包括孟子的,为什么要再写一次?  我想我们不仅仅要会实现,更多的是需要理解。  下面先帖出代码,再分析一下其中的一些关键代码。  数据库表名:tb1,其中有...

easyui datagrid 生成动态列后 实现分页

easyui是一个比较简单的前端框架,相比Extjs有很大的性能提升,但是对很多处理来说easyui支持的不是很好 下面介绍datagrid动态列生成之后如何实现分页 easyui dat...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:深度学习:神经网络中的前向传播和反向传播算法推导
举报原因:
原因补充:

(最多只允许输入30个字)