none
MS Knowledge Base: Bagaimana menggunakan DataList control untuk membuat Image Gallery? (Part 3) RRS feed

  • Diskusi Umum

  • 10. Sisipkan kode berikut untuk menjalankan page button events:

    //handle the navigation button event

            public void Page_OnClick(Object sender, CommandEventArgs e)

            {

                if (e.CommandName == "first")

                {

                    Page_Index = 0;

                    lbnFirstPage.Enabled = false;

                    lbnPrevPage.Enabled = false;

                    lbnNextPage.Enabled = true;

                    lbnLastPage.Enabled = true;

                }

                else if (e.CommandName == "prev")

                {

                    Page_Index -= 1;

                    if (Page_Index == 0)

                    {

                        lbnFirstPage.Enabled = false;

                        lbnPrevPage.Enabled = false;

                        lbnNextPage.Enabled = true;

                        lbnLastPage.Enabled = true;

                    }

                    else

                    {

                        lbnFirstPage.Enabled = true;

                        lbnPrevPage.Enabled = true;

                        lbnNextPage.Enabled = true;

                        lbnLastPage.Enabled = true;

                    }

                }

                else if (e.CommandName == "next")

                {

                    Page_Index += 1;

                    if (Page_Index == Page_Count - 1)

                    {

                        lbnFirstPage.Enabled = true;

                        lbnPrevPage.Enabled = true;

                        lbnNextPage.Enabled = false;

                        lbnLastPage.Enabled = false;

                    }

                    else

                    {

                        lbnFirstPage.Enabled = true;

                        lbnPrevPage.Enabled = true;

                       lbnNextPage.Enabled = true;

                        lbnLastPage.Enabled = true;

                    }

                }

                else if (e.CommandName == "last")

                {

                    Page_Index = Page_Count - 1;

                    lbnFirstPage.Enabled = true;

                    lbnPrevPage.Enabled = true;

                    lbnNextPage.Enabled = false;

                    lbnLastPage.Enabled = false;

                }

     

                DataList1.SelectedIndex = 0;

                DataList1.DataSource = BindGrid();

                DataList1.DataBind();

                Image1.ImageUrl

                   = ((Image)DataList1.Items[0].FindControl("IB_tn")).ImageUrl;

            }

     

     

    11. Sisipkan kode berikut untuk menjalankan image click events:

    //handle the thumbnail image selecting event

            protected void IB_tn_Click(object sender, EventArgs e)

            {

                ImageButton ib = (ImageButton)sender;

                Image1.ImageUrl = ib.ImageUrl;

                DataList1.SelectedIndex = Convert.ToInt32(ib.CommandArgument);

      }

    Kategori Teknologi

    ·         ASP.NET 2.0

    ·         ASP.NET 3.5

    ·         ASP.NET 4.0

    Bahasa Pemograman

     

    Contoh kode ini memuat bahasa pemograman dibawah ini:Collapse this tableExpand this tableCollapse this tableExpand this tableCollapse this tableExpand this tableCollapse this tableExpand this table

    Language

    Project Name

    Visual C#

    CSASPNETDataListImageGallery

    Visual Basic.NET

    VBASPNETDataListImageGallery

    Link

    For more information about the DataList server control, visit the following Microsoft Developer (MSDN) website:

    General information about the DataList server control (http://msdn.microsoft.com/en-us/library/9cx2f3ks(VS.85).aspx)

    For more information about how to decide when to use the DataGrid, DataList and Repeater control, visit the following MSDN website:

    How to decide when to use the DataGrid, DataList and Repeater control (http://msdn.microsoft.com/en-us/library/aa479015.aspx)

    For more information about the efficient data paging with the ASP.NET 2.0 DataList control and ObjectDataSource, visit the following websit:

    General information about the efficient data paging with the ASP.NET 2.0 DataList control and ObjectDataSource (http://weblogs.asp.net/scottgu/archive/2006/01/07/434787.aspx)

    Referensi

    http://support.microsoft.com/kb/2512242/en-us
    Agnes Sannie [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Rabu, 01 Juni 2011 07.15
    Moderator