วันศุกร์ที่ 16 พฤษภาคม พ.ศ. 2557

แบ่งหน้าใน 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 

วันอังคารที่ 13 พฤษภาคม พ.ศ. 2557

วันพุธที่ 7 พฤษภาคม พ.ศ. 2557

Repeater1_ItemDataBound

Private Sub Repeater1_ItemDataBound(sender As Object, e As RepeaterItemEventArgs) Handles Repeater1.ItemDataBound
        Dim ltrmActivities_LimitMax As Literal = CType(e.Item.FindControl("ltrmActivities_LimitMax"), Literal)
        Dim mActivities_LimitMax As HiddenField = CType(e.Item.FindControl("mActivities_LimitMax"), HiddenField)

End Sub

วันพุธที่ 20 พฤศจิกายน พ.ศ. 2556

GridView:RowDataBound

Private Sub GridView1_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GridView1.RowDataBound
        If e.Row.RowType = DataControlRowType.DataRow Then
            Try
                Dim numss As Label = CType(e.Row.FindControl("lblNum"), Label)

            Catch ex As Exception

            End Try
        End If


End Sub

วันอังคารที่ 22 ตุลาคม พ.ศ. 2556

stored procedure วนรอบข้อมูลในตาราง A แล้ว insert ลงตาราง B ได้หลายๆเรคคอร์ด


Stored Procedure

เมื่อใช้ stored procedure ในครั้งแรก ทุกคนจะตื่นเต้นเสมอ คำกล่าวนี้เป็นจริง

แบบที่ 1 
CREATE PROCEDURE dbo.SelectViewInsertToTable
(
     ใส่ตัวแปรพารามิเตอร์ที่จะรับผ่านฟอร์มเข้ามา
)
AS
BEGIN
   INSERT INTO TableBB(b1,b2,b3)
   select a1,a2,a3 from View_AA  where a4='0'
END

GO

การใช้ WebClient สำหรับเรียก URL

Dim _url As String = " https :// www . MyDomain . com /?q=ทดสอบ " Dim wc As New System . Net . WebClient () wc . Encodin...