วันอาทิตย์ที่ 25 พฤษภาคม พ.ศ. 2557
วันเสาร์ที่ 17 พฤษภาคม พ.ศ. 2557
เลขลำดับแถว RunNumber แบบลำดับหลายหน้า
<%# (GridView1.PageIndex *
GridView1.PageSize) + (Container.DataItemIndex + 1)%>
******************************************************************************
<asp:GridView ID="GridView1" runat="server"
AllowPaging="True" AutoGenerateColumns="False" GridLines="None" Width="100%" ShowHeader="False" PageSize="10" >
<Columns>
<asp:HyperLinkField />
<asp:TemplateField>
<ItemTemplate >
<span>
<%# (GridView1.PageIndex * GridView1.PageSize) +
(Container.DataItemIndex + 1)%>
</span>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<PagerStyle CssClass="pager" />
</asp:GridView>
วันศุกร์ที่ 16 พฤษภาคม พ.ศ. 2557
คิวรี่ LinqDataSource แบบ Like เพื่อใช้ในการแบ่งหน้า
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If IsPostBack = False Then
getFind(0)
End If
End Sub
Sub getFind(PageIndex As Integer)
Dim sql As New StringBuilder
sql.Append("mActivities_Name.Contains(""" & txtFind.Text & """)")
sql.Append("|| mActivities_teacher.Contains(""" & txtFind.Text & """)")
sql.Append("|| mActivities_place.Contains(""" & txtFind.Text & """)")
sql.Append("|| mActivities_note.Contains(""" & txtFind.Text & """)")
LinqDataSource1.WhereParameters.Clear()
LinqDataSource1.Where = sql.ToString
LinqDataSource1.DataBind()
GridView1.DataSourceID = "LinqDataSource1"
GridView1.PageIndex = PageIndex
GridView1.DataBind()
End Sub
Private Sub GridView1_PageIndexChanging(sender As Object, e As GridViewPageEventArgs) Handles
GridView1.PageIndexChanging
getFind(e.NewPageIndex)
End Sub
***********************************************
<asp:LinqDataSource ID="LinqDataSource1" runat="server" ContextTypeName="studentActivities.DataClasses_ViewDataContext"
EntityTypeName="" OrderBy="mActivities_Name" TableName="View_mActivities_Selects">
</asp:LinqDataSource>
<asp:GridView ID="GridView1" runat="server"
AllowPaging="True" AutoGenerateColumns="False" >
<Columns>
<asp:BoundField DataField="mActivities_ID" HeaderText="mActivities_ID" SortExpression="mActivities_ID" />
</Columns>
<PagerStyle CssClass="pager" />
</asp:GridView>
แบ่งหน้าใน GridView โดยใช้ object
<asp:GridView ID="GridView1" runat="server"
AllowPaging="true" PageSize="10" AutoGenerateColumns="true">
<PagerStyle CssClass="pager" />
</asp:GridView>
*****************************
Private Sub GridView1_PageIndexChanging(sender As Object, e As GridViewPageEventArgs) Handles
GridView1.PageIndexChanging
Dim obj As New DataClasses_ViewDataContext
GridView1.PageIndex = e.NewPageIndex
GridView1.DataSource =
obj.mActivities_Select("ระงับกิจกรรม", 0, "")
GridView1.DataBind()
End Sub
วันพุธที่ 14 พฤษภาคม พ.ศ. 2557
สุ่มแบบไม่ซ้ำใน vb.net ใน Array
Imports System.Security.Cryptography
Public Class ArrayUtilities
Private Random As RNGCryptoServiceProvider = New RNGCryptoServiceProvider
Private Bytes(4) As Byte
Public Function ShuffleArray(ByVal argArr As Array) As Array
Dim FirstArray As New ArrayList(argArr)
Dim SecoundArray As Array = Array.CreateInstance(GetType(Object), FirstArray.Count)
Dim intIndex As Integer
For i As Integer = 0 To FirstArray.Count - 1
intIndex = RandomNumber(FirstArray.Count)
SecoundArray(i) = FirstArray(intIndex)
FirstArray.RemoveAt(intIndex)
Next
FirstArray = Nothing
Return SecoundArray
End Function
Private Function RandomNumber(ByVal argMax As Integer) As Integer
If argMax <= 0 Then Throw New Exception
Random.GetBytes(Bytes)
Dim intValue As Integer = (BitConverter.ToInt32(Bytes, 0)) Mod argMax
If intValue < 0 Then intValue = -intValue
Return intValue
End Function
End Class
Module Module1
Sub Main()
Dim AU As ArrayUtilities
AU = New ArrayUtilities
Dim GivenArray As Integer() = {11, 12, 13, 14, 15, 16, 17, 18, 19, 20}
Dim NewArray As Array = AU.ShuffleArray(GivenArray)
Dim i As Integer
Dim stb As New System.Text.StringBuilder
stb.Append("GivenArray = {11, 12, 13, 14, 15, 16, 17, 18, 19, 20}")
stb.Append(vbCrLf)
stb.Append("NewArray = {")
For i = 0 To NewArray.Length - 2
stb.Append(NewArray(i).ToString)
stb.Append(", ")
Next
stb.Append(NewArray(NewArray.Length - 1).ToString)
stb.Append("}")
Console.Write(stb.ToString)
Console.Read()
End Sub
End Module
Public Class ArrayUtilities
Private Random As RNGCryptoServiceProvider = New RNGCryptoServiceProvider
Private Bytes(4) As Byte
Public Function ShuffleArray(ByVal argArr As Array) As Array
Dim FirstArray As New ArrayList(argArr)
Dim SecoundArray As Array = Array.CreateInstance(GetType(Object), FirstArray.Count)
Dim intIndex As Integer
For i As Integer = 0 To FirstArray.Count - 1
intIndex = RandomNumber(FirstArray.Count)
SecoundArray(i) = FirstArray(intIndex)
FirstArray.RemoveAt(intIndex)
Next
FirstArray = Nothing
Return SecoundArray
End Function
Private Function RandomNumber(ByVal argMax As Integer) As Integer
If argMax <= 0 Then Throw New Exception
Random.GetBytes(Bytes)
Dim intValue As Integer = (BitConverter.ToInt32(Bytes, 0)) Mod argMax
If intValue < 0 Then intValue = -intValue
Return intValue
End Function
End Class
Module Module1
Sub Main()
Dim AU As ArrayUtilities
AU = New ArrayUtilities
Dim GivenArray As Integer() = {11, 12, 13, 14, 15, 16, 17, 18, 19, 20}
Dim NewArray As Array = AU.ShuffleArray(GivenArray)
Dim i As Integer
Dim stb As New System.Text.StringBuilder
stb.Append("GivenArray = {11, 12, 13, 14, 15, 16, 17, 18, 19, 20}")
stb.Append(vbCrLf)
stb.Append("NewArray = {")
For i = 0 To NewArray.Length - 2
stb.Append(NewArray(i).ToString)
stb.Append(", ")
Next
stb.Append(NewArray(NewArray.Length - 1).ToString)
stb.Append("}")
Console.Write(stb.ToString)
Console.Read()
End Sub
End Module
สมัครสมาชิก:
บทความ (Atom)
การใช้ WebClient สำหรับเรียก URL
Dim _url As String = " https :// www . MyDomain . com /?q=ทดสอบ " Dim wc As New System . Net . WebClient () wc . Encodin...
-
#Region "-- แสดงตัวเลขเป็นตัวหนังสือ --" Public Function NumberToThaiWord( ByVal InputNumber As Double ) As Strin...
-
<asp:TemplateField> <ItemTemplate> <% # Container.DataItemIndex + 1 %> </ItemTemplate> </asp:...
-
< script type =" text / javascript " > function getData_ashx () { var response = '' ; ...