PIXNET Logo登入

ANdyYoU_蹤雁_數位記錄本

跳到主文

Something About TsungYen You_游宗諺

部落格全站分類:生活綜合

  • 相簿
  • 部落格
  • 留言
  • 名片
  • 8月 23 週一 201018:00
  • [.NET] GridView 自訂分頁 SOP 快速步驟

GridView 自訂分頁
http://dotnetmis91.blogspot.com/2008/08/gridview_20.html
本文為參考坎尼大大的文章 做成的快速製作版 如果趕時間可以馬上完成的步驟紀錄

1. 自訂Pager Templete, 將相關物件拉進Pager 或直接貼程式碼:  注意程式碼的部分已經將Click的程序名稱掛上去 若 是自己用啦的請注意程序名稱,文字部分可自行換成圖片 直接加在</Columns> 或 <AlternatingRowStyle>  下,在</asp:GridView>內。

<PagerTemplate>

            <asp:Label ID="Label1" runat="server" ></asp:Label>

           
<asp:LinkButton ID="lbtnfirst" runat="server" CommandArgument="first"
OnClick="Query_Click" >First</asp:LinkButton>

           
<asp:LinkButton ID="lbtnPrevious" runat="server"
CommandArgument="previous" OnClick="Query_Click"
>Previous</asp:LinkButton>

           
<asp:LinkButton ID="lbtnnext" runat="server" CommandArgument="next"
OnClick="Query_Click" >Next</asp:LinkButton>

           
<asp:LinkButton ID="lbtnlast" runat="server" CommandArgument="last"
OnClick="Query_Click">Last</asp:LinkButton>

           
<asp:DropDownList ID="DropDownList1" runat="server"
OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged"
AutoPostBack="True">

            </asp:DropDownList>

            <asp:Label ID="Label2" runat="server" ></asp:Label>





2. 貼入相關C#程序,若需要相關說明請參考坎尼大大的文章:

    protected void Query_Click(object sender, EventArgs e) {

        int intPageIndex = 0;

        LinkButton lkbtn = (LinkButton)sender;

        switch (lkbtn.CommandArgument.ToString()) {

            case "previous":

                if (GridView1.PageIndex > 0) {

                    intPageIndex = GridView1.PageIndex - 1;

                } break;

            case "next":

                if (GridView1.PageIndex < GridView1.PageCount - 1) {

                    intPageIndex = GridView1.PageIndex + 1;

                } break;

            case "last":

                intPageIndex = GridView1.PageCount - 1;

                break;   

        }

        GridView1.PageIndex = intPageIndex;

    }



   



    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)

    {

        DropDownList ddlPage = ((DropDownList)GridView1.BottomPagerRow.FindControl("DropDownList1"));

        GridView1.PageIndex = ddlPage.SelectedIndex;

    }



    protected void GridView1_DataBound(object sender, EventArgs e)

    {

        pageSet(GridView1);

    }

    public void pageSet(object gvQuery) {

        GridView gv = (GridView)gvQuery;

        Label lbCount = (Label)gv.BottomPagerRow.FindControl("Label1");

        Label lbPage = (Label)gv.BottomPagerRow.FindControl("Label2");

        DropDownList ddlJump = (DropDownList)gv.BottomPagerRow.FindControl("DropDownList1");



        lbCount.Text = "共 " + (gv.PageSize * gv.PageCount).ToString() + " 筆"; // 要精準的部份需另外判斷!

        lbPage.Text = "共 " + gv.PageCount + " 頁";



        for (int i = 1; i <= gv.PageCount; i++) {

            ddlJump.Items.Add(new ListItem(i.ToString()));



            if (gv.PageIndex == 0) {

                ((LinkButton)gv.BottomPagerRow.FindControl("lbtnfirst")).Enabled = false;

                ((LinkButton)gv.BottomPagerRow.FindControl("lbtnPrevious")).Enabled = false;

            }

            else if (gv.PageIndex == (gv.PageCount - 1)) {

                ((LinkButton)gv.BottomPagerRow.FindControl("lbtnnext")).Enabled = false;

                ((LinkButton)gv.BottomPagerRow.FindControl("lbtnlast")).Enabled = false;

            }

            ddlJump.SelectedIndex = gv.PageIndex;

           

        }

    }





3. 設定GridView 相關屬性或直接加上程式碼部分加上觸發事件部份



<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AutoGenerateColumns="False"

            CellPadding="4" DataKeyNames="id" DataSourceID="SqlDataSource1" ForeColor="#333333"

              OnDataBound="GridView1_DataBound">


(繼續閱讀...)
文章標籤

andyyu0920 發表在 痞客邦 留言(2) 人氣(3,032)

  • 個人分類:Program
▲top
  • 8月 16 週一 201015:36
  • [AJAX]開啟Div移動 iframe 應用

由於急需要一些簡單的JS效果,剛好去對岸借了一個範例來改有需要的就拿去吧! 整篇貼到HTML即可執行 如果要分檔案再把CSS和JS分離吧



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf8" />
<title>Div+IFram 應用</title>
<style type="text/css">
#bodyR{
float:right;
width:80px;
margin-right:0px;
}
a.od{
width:120px;
height:20px;
line-height:20px;
text-align:center;
border: 1px solid #DDD;
display:block;
color:#333;
float:right;
text-decoration:none;
}
a.od:link{
background:#EEE;
}
a.od:visited{
background:#EEE;
}
a.od:hover{
background:#FFF;
}
a.od:active{
background:#EEE;
}
#fd{
background:#FFF;
border: 1px solid #DDD;
margin-top:1px;
margin-right:1px;
float:right;
overflow:hidden;
position:inherit;
cursor:move;
float:right;
}
.content{
padding:0px;
}
a.od2{
width:20px;
height:20px;
line-height:20px;
text-align:center;
border: 1px solid #DDD;
display:block;
color:#000;
float:right;
text-decoration:none;
}
a.od2:link{
background:#FFF;
}
a.od2:visited{
background:#EEF1F8;
}
a.od2:hover{
background:#EEE;
}
a.od2:active{
background:#EEE;
}
</style>
</head>
<body>
<div id="bodyR">
<a href="#" onclick = "show('fd');return false;">
展開DiV  +Ifram 移動應用
</a>
</div>
<div id="fd" style="display:none;filter:alpha(opacity=100);opacity:1;">
<div>
<a href="#" onclick = "closeed('fd');return false;">X</a>
<iframe src="http://www.google.com" id="frameid" frameborder="0"  height="600" scrolling="no" width="300"></iframe>
</div>
</div>
<script type="text/javascript">
var prox;
var proy;
var proxc;
var proyc;
function show(id){
clearInterval(prox);
clearInterval(proy);
clearInterval(proxc);
clearInterval(proyc);
var o = document.getElementById(id);
o.style.display = "block";
o.style.width = "1px";
o.style.height = "1px";
prox = setInterval(function(){openx(o,300)},10);
}
function openx(o,x){
var cx = parseInt(o.style.width);
if(cx < x)
{
o.style.width = (cx + Math.ceil((x-cx)/5)) +"px";
}
else
{
clearInterval(prox);
proy = setInterval(function(){openy(o,300)},10);
}
}
function openy(o,y){
var cy = parseInt(o.style.height);
if(cy < y)
{
o.style.height = (cy + Math.ceil((y-cy)/5)) +"px";
}
else
{
clearInterval(proy);
}
}
function closeed(id){
clearInterval(prox);
clearInterval(proy);
clearInterval(proxc);
clearInterval(proyc);
var o = document.getElementById(id);
if(o.style.display == "block")
{
proyc = setInterval(function(){closey(o)},10);
}
}
function closey(o){
var cy = parseInt(o.style.height);
if(cy > 0)
{
o.style.height = (cy - Math.ceil(cy/5)) +"px";
}
else
{
clearInterval(proyc);
proxc = setInterval(function(){closex(o)},10);
}
}
function closex(o){
var cx = parseInt(o.style.width);
if(cx > 0)
{
o.style.width = (cx - Math.ceil(cx/5)) +"px";
}
else
{
clearInterval(proxc);
o.style.display = "none";
}
}
var od = document.getElementById("fd");
var dx,dy,mx,my,mouseD;
var odrag;
var isIE = document.all ? true : false;
document.onmousedown = function(e){
var e = e ? e : event;
if(e.button == (document.all ? 1 : 0))
{
mouseD = true;
}
}
document.onmouseup = function(){
mouseD = false;
odrag = "";
if(isIE)
{
od.releaseCapture();
od.filters.alpha.opacity = 100;
}
else
{
window.releaseEvents(od.MOUSEMOVE);
od.style.opacity = 1;
}
}
//function readyMove(e){
od.onmousedown = function(e){
odrag = this;
var e = e ? e : event;
if(e.button == (document.all ? 1 : 0))
{
mx = e.clientX;
my = e.clientY;
od.style.left = od.offsetLeft + "px";
od.style.top = od.offsetTop + "px";
if(isIE)
{
od.setCapture();
od.filters.alpha.opacity = 50;
}
else
{
window.captureEvents(Event.MOUSEMOVE);
od.style.opacity = 0.5;
}
//alert(mx);
//alert(my);
}
}
document.onmousemove = function(e){
var e = e ? e : event;
//alert(mrx);
//alert(e.button);
if(mouseD==true && odrag)
{
var mrx = e.clientX - mx;
var mry = e.clientY - my;
od.style.left = parseInt(od.style.left) +mrx + "px";
od.style.top = parseInt(od.style.top) + mry + "px";
mx = e.clientX;
my = e.clientY;
}
}
</script>
</body>
</html>
(繼續閱讀...)
文章標籤

andyyu0920 發表在 痞客邦 留言(0) 人氣(811)

  • 個人分類:Program
▲top
  • 8月 09 週一 201010:52
  • [.NET]錯誤訊息 DataBinding: 'System.Data.DataRowView'

錯誤訊息 : DataBinding: 'System.Data.DataRowView' 沒有包含名為 'id' 的屬性。
今天一大早要建一個簡單的資料庫連結+TSQL自訂撈資料,很順手的用VWD的精靈就把資料庫繫結好了外加GridView也綁定
結果在一個Botton_Click程序中 我要重新SELECT卻出現上敘的錯誤訊息。
主要是因為當然使用VWD介面去建立這些物件時他會自動幫您,產生的程式碼造成的干擾
  <Columns>
    <asp:BoundField DataField="id" HeaderText="id" InsertVisible="False" ReadOnly="True" SortExpression="id" />
    <asp:BoundField DataField="name" HeaderText="name" SortExpression="name" />
    <asp:BoundField DataField="info" HeaderText="info" SortExpression="info" />
  </Columns>
將自動產生的<Columns> 屬性刪除即可
另外 AutoGenerateColumns="false" 這個屬性為false的話 使用程序去修改SQL 資料無法直接顯示在Gridview
若需要使用程序來動態決定SQL的話實際上控制項的原碼如以下即可 :
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings: [ 控制項連接字串 ]  %>" 
></asp:SqlDataSource>
<asp:GridView ID="GridView1" runat="server" DataSourceID="SqlDataSource1"></asp:GridView>
(繼續閱讀...)
文章標籤

andyyu0920 發表在 痞客邦 留言(0) 人氣(2,676)

  • 個人分類:Program
▲top
  • 8月 06 週五 201014:04
  • [.NET]使用CKeditor in ASP.NET For C#

由於之前開發PHP很多OPEN SOURCE都有提供且很多熱心的神人都會在網路上PO文這篇文章純粹是紀錄因為工作上需要使用.NET 來做HTMLEditor
由於採用.dll舊的作法 FF和CH會不正常 所以花了一個早上整理這篇文章做個紀錄:
CKeditor in ASP.NET

1. 至官方下載 http://ckeditor.com/download

2. 解開壓鎖檔後刪除不必要的檔案 _samples _source 目錄以減少檔案容量。

3. 複製該目錄至您的.NET專案底下

4. 在<head></head>中間引入Ckeditor 的JS 核心 :
<script type="text/javascript" src="ckeditor/ckeditor.js"></script>

在HEAD中如下:

<head runat="server">
    <title>HTML Editor</title>
<script type="text/javascript" src="ckeditor/ckeditor.js"></script>
</head>

5. 在Form中間插入Textbox物件 或切換到原始碼頁面插入  注意: ID可以自行設定
<asp:TextBox ID="tbContent" name="tbContent" runat="server" TextMode="MultiLine"></asp:TextBox>

6. 接著在上面那段程式碼下方插入下面這段JS

<script type="text/javascript">
     //CKEDITOR.replace('tbContent');
     CKEDITOR.replace('<%=tbContent.ClientID.Replace("_","$") %>');
</script>

重點程式註解 :
CKEDITOR.replace('<%=[物件ID].ClientID.Replace("_","$") %>',{toolbar:'[ 工具列的屬性 可設定 Basic 或 Full ]});

7. 大部分的文章到此為止算是把CKeditor 搬到自己的網頁上了 但是後續還需要把 輸入的資料 取出

將Page 指示詞修改為  :
<%@ Page Language="C#" ValidateRequest="false" %>

8. 使用ToolBar上面提供的Save按鈕

protected void Page_Load(object sender, EventArgs e)
    {   
        if (IsPostBack) {
            Label1.Text += HttpUtility.HtmlEncode(Request.Form["tbContent"].ToString());
        }
    }

9. 到此已經可以取得需要的值了 應可以帶入資料庫等。
整個頁面的程式碼 :
<%@ Page Language="C#" ValidateRequest="false" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
    protected void Page_Load(object sender, EventArgs e)
    {  
        if (IsPostBack) {
            Label1.Text += HttpUtility.HtmlEncode(Request.Form["tbContent"].ToString());
        }
    } 
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>HTML Editor</title>
<script type="text/javascript" src="ckeditor/ckeditor.js"></script>
</head>
<body>
    <form id="form1" runat="server"  >
    <div>
    <asp:TextBox ID="tbContent" name="tbContent" runat="server" TextMode="MultiLine"></asp:TextBox>
        <br />
        <asp:Label ID="Label1" runat="server">Save to Try Get Value</asp:Label></div>
    <script type="text/javascript">
        //CKEDITOR.replace('tbContent');
        CKEDITOR.replace('<%=tbContent.ClientID.Replace("_","$") %>',{toolbar:'Andybar'});
    </script>
    </form>
</body>
</html>


10. 如果想修改ToolBar的按鈕請到Ckeditor目錄中找到 config.js 開啟後 加入藍色段落
由於Basic 太過陽春 故藍色段落為筆者自行針對比較常用的功能設計的Toolbar 下面為開啟後看到的程式碼 :

/*
Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.html or http://ckeditor.com/license
*/

CKEDITOR.editorConfig = function( config )
{
    // Define changes to default configuration here. For example:
    // config.language = 'fr';
    // config.uiColor = '#AADC6E';
    config.toolbar_Andybar =
    [  
        ['Source'],
        ['Save','Undo','Redo','Find','Replace','SelectAll'],
        ['Cut','Copy','Paste','PasteText','PasteFromWord','-','Scayt'],
        ['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'],
        ['Image','Table','HorizontalRule','SpecialChar'],
        '/',
        ['Styles','Format','PasteFromWord'],
        ['Bold','Italic','Strike','TextColor','BGColor'],
        ['NumberedList','BulletedList','-','Outdent','Indent','Blockquote'],
        ['Link','Unlink','Anchor']
    ];
};

下面是 按鈕的對照表 :
(繼續閱讀...)
文章標籤

andyyu0920 發表在 痞客邦 留言(0) 人氣(7,063)

  • 個人分類:Program
▲top
  • 8月 03 週二 201010:44
  • [.NET]IIS 安裝BUG

安裝IIS時出現下面的錯誤訊息,大致上推測原因及發生的機器大部分可能為公司機器再使用者群組上有一些資安的設定

Server Application Error
The server has encountered an error while loading an application during the processing of your request. Please refer to the event log for more detail information. Please contact the server administrator for assistance



解決方案 :
(繼續閱讀...)
文章標籤

andyyu0920 發表在 痞客邦 留言(0) 人氣(74)

  • 個人分類:Program
▲top
  • 2月 15 週一 201021:15
  • [Linux]小小技巧紀錄,開機設定

如果選擇安裝圖形介面,那重開機後一般都會直接進入圖形介面模式,此時,可以修改/etc/inittab
id:3:initdefault:
 
(繼續閱讀...)
文章標籤

andyyu0920 發表在 痞客邦 留言(0) 人氣(92)

  • 個人分類:Linux
▲top
  • 2月 08 週一 201022:25
  • [Linux]安裝PAM 紀錄


安裝MySQL-Server
$ sudo apt-get install mysql-server
安裝Apache HTTP Server
$ sudo apt-get install apache2
安裝PHP for Apache HTTP Server
$ sudo apt-get install php5
安裝MySQL for Apache HTTP Server
$ sudo apt-get install libapache2-mod-auth-mysql
$ sudo apt-get install php5-mysql




安裝phpMyAdmin
$ sudo apt-get install phpmyadmin
(繼續閱讀...)
文章標籤

andyyu0920 發表在 痞客邦 留言(0) 人氣(133)

  • 個人分類:Linux
▲top
  • 2月 08 週一 201022:25
  • [Linux]安裝PAM 紀錄

安裝MySQL-Server
$ sudo apt-get install mysql-server
安裝Apache HTTP Server
$ sudo apt-get install apache2
安裝PHP for Apache HTTP Server
$ sudo apt-get install php5
安裝MySQL for Apache HTTP Server
$ sudo apt-get install libapache2-mod-auth-mysql
$ sudo apt-get install php5-mysql
PS.
資料庫預設目錄:/var/lib/mysql
網頁預設目錄:/var/www
Apache設定檔:/etc/apache2/apache2.conf
Apache log檔 /var/log/apache2
php session 存在 /var/lib/php5
php /etc/php5
(繼續閱讀...)
文章標籤

andyyu0920 發表在 痞客邦 留言(0) 人氣(116)

  • 個人分類:Linux
▲top
  • 2月 06 週六 201019:01
  • [PHP]Xdebug

完整的初學者教學
http://www.lsproc.com/blog/install_xdebug/
http://www.phpq.net/tutorial/xdebug-debug.html
(繼續閱讀...)
文章標籤

andyyu0920 發表在 痞客邦 留言(0) 人氣(136)

  • 個人分類:Linux
▲top
  • 2月 05 週五 201022:05
  • [Network] Tools Pingdom


Link
分析網頁載入時各程式語法和圖片等細部的時間
 
 
(繼續閱讀...)
文章標籤

andyyu0920 發表在 痞客邦 留言(0) 人氣(23)

  • 個人分類:Network
▲top
12...7»

Adsence

個人頭像

andyyu0920
暱稱:
andyyu0920
分類:
生活綜合
好友:
累積中
地區:

文章分類

toggle Learn_學習紀錄 (5)
  • Network (3)
  • Design (5)
  • HTML&CSS (7)
  • Computer (3)
  • Program (12)
toggle Mind_隨記 (3)
  • Diary (16)
  • Empiricism (8)
  • Think (2)
  • Linux (7)
  • 未分類文章 (1)

近期文章

  • [.NET] GridView 自訂分頁 SOP 快速步驟
  • [AJAX]開啟Div移動 iframe 應用
  • [.NET]錯誤訊息 DataBinding: 'System.Data.DataRowView'
  • [.NET]使用CKeditor in ASP.NET For C#
  • [.NET]IIS 安裝BUG
  • [Linux]小小技巧紀錄,開機設定
  • [Linux]安裝PAM 紀錄
  • [Linux]安裝PAM 紀錄
  • [PHP]Xdebug
  • [Network] Tools Pingdom

參觀人氣

  • 本日人氣:
  • 累積人氣:

MyBlogLog

BloggerAds

ADS

Other

2010痞客邦生日慶

大聯盟世界

文章彙整

MyICON

Yahoo站長工具分析

Yahoo追蹤貼紙