Yazı Font Küçült Yazı Font Büyült

Yükleniyor Uyarısından Sonra Update Panel İçerisindeki GridView Nesnesine  Veri Aktarımı Yapmak

 

Merhaba arkadaşlar bu makalemizde UpdatePanel  içindeki veri al butonuna bastığımızda ilk önce loading image i ekrana gelecek ve daha sonra Update panelindeki GridView a verileri aktacağız.

 

 

Screenshot

Resim1 

Şekil 1



Resim2 

Şekil 2

 

Default.aspx.cs

using System;

using System.Collections.Generic;

using System.Data;

using System.Data.SqlClient;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

 

public partial class _Default : System.Web.UI.Page

{

    protected void Page_Load(object sender, EventArgs e)

    {

      

    }

 

    protected void btnGet_Click(object sender, EventArgs e)

    {

        BindGridview();

    }

 

    protected void BindGridview()

    {

        DataSet ds = new DataSet();

        using (SqlConnection con = new SqlConnection("Data Source=(LocalDB)\\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\\kategori.mdf;Integrated Security=True"))

        {

            con.Open();

            SqlCommand cmd = new SqlCommand("select * from [dbo].[Table]", con);

            SqlDataAdapter da = new SqlDataAdapter(cmd);

            da.Fill(ds);

            con.Close();

            gvDetails.DataSource = ds;

            gvDetails.DataBind();

        }

        System.Threading.Thread.Sleep(2000);

    }

    protected void gvDetails_PageIndexChanging(object sender, GridViewPageEventArgs e)

    {

        gvDetails.PageIndex = e.NewPageIndex;

        BindGridview();

    }

 

}

 

Default.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

 

<!DOCTYPE html>

 

<html xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">

    <title></title>

    <style type="text/css">

 

.overlay

{

position: fixed;

z-index: 999;

height: 100%;

width: 100%;

top: 0;

background-color: Black;

filter: alpha(opacity=60);

opacity: 0.6;

-moz-opacity: 0.8;

}

.GridviewDiv {font-size: 100%; font-family: 'Lucida Grande', 'Lucida Sans Unicode', Verdana, Arial, Helevetica, sans-serif; color: #303933;}

.headerstyle

{

color:#FFFFFF;border-right-color:#abb079;border-bottom-color:#abb079;background-color: #df5015;padding:0.5em 0.5em 0.5em 0.5em;text-align:center;

}

</style>

<script type="text/javascript">

function showProgress() {

var updateProgress = $get("<%= UpdateProgress.ClientID %>");

updateProgress.style.display = "block";

}

</script>

 

</head>

<body>

    <form id="form1" runat="server">

   <asp:ScriptManager ID="scriptmanager1" runat="server"></asp:ScriptManager>

<asp:UpdatePanel runat="server" ID="updatepanel1" UpdateMode="Conditional">

<ContentTemplate>

<div style="align:center; margin-left:350px; margin-top:150px">

<asp:Button ID="btnUpload" Text="Veri Al" runat="server" onclick="btnGet_Click" OnClientClick="showProgress()" /><br /><br />

<div class="GridviewDiv">

<asp:GridView runat="server" ID="gvDetails" AllowPaging="true" PageSize="5" AutoGenerateColumns="false" Width="420px" OnPageIndexChanging="gvDetails_PageIndexChanging">

<HeaderStyle CssClass="headerstyle" />

<Columns>

<asp:BoundField DataField="Id" HeaderText="Product Id" />

<asp:BoundField DataField="Yazar" HeaderText="Product Name" />

<asp:BoundField DataField="Kitap" HeaderText="Price" />

</Columns>

</asp:GridView>

</div>

 

</div>

</ContentTemplate>

<Triggers>

<asp:PostBackTrigger ControlID="btnUpload" />

</Triggers>

</asp:UpdatePanel>

<asp:UpdateProgress ID="UpdateProgress" runat="server" AssociatedUpdatePanelID="updatepanel1">

<ProgressTemplate>

<div class="overlay">

<div style=" z-index: 1000; margin-left: 500px;margin-top:330px;opacity: 1;-moz-opacity: 1;">

<img alt="" src="loading.gif" />

</div>

</div>

</ProgressTemplate>

</asp:UpdateProgress>

 

    </form>

</body>

</html>

Bir makalenin daha sonuna geldik. Bir sonraki makalede görüşmek üzere. Bahadır ŞAHİN