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,680)

  • 個人分類: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
  • 1月 18 週一 201014:37
  • [PHP]Rewrite


在從事網管的工作其實遇到很多的問題反而是網頁設計師的問題= =a 但業主是不會理這種事情的
反正就是要解決問題!
今天遇到的是Rewrite的問題!
再Google一陣子之後看了很多「中文」的文章但是一直無法解決我的問題
(繼續閱讀...)
文章標籤

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

  • 個人分類:Program
▲top
  • 1月 12 週二 201017:33
  • [分享].htaccess 線上 簡易製作

設定一下即生成.htaccess 大部分的功能屬於陽春且 比較常用的
http://www.htaccesseditor.com/tc.shtml
(繼續閱讀...)
文章標籤

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

  • 個人分類:Program
▲top
  • 8月 21 週四 200814:53
  • [程式]W3C School

在學習程式語言的路上尤其是偏向網路應用這方面有這兩個網站真是省了不少錢。
 
http://www.w3schools.com/
簡體中文版的,目前還沒找到繁體的就將就一下嚕!
(繼續閱讀...)
文章標籤

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

  • 個人分類:Program
▲top
  • 8月 17 週日 200817:03
  • [程式]AutoGuarder : Solve some problem of USB virus

Q:電腦防毒軟體偵測出有蠕蟲病毒,USB病毒,使用防毒軟體刪除該病毒之後卻無法正常開啟C,D槽.
或者開啟時會詢問該使用什麼程式開啟.
A:上敘問題只要使用對岸的一個好用的防毒小工具就可以解決了.
AutoGuarder
解決問題之後可以繼而使用這個軟體所提供的另一個功能,免疫USB病毒.在隨身碟便宜到到處亂「插」的情況下.
雖然不能保證之後會有更強大的病毒出現,不過短期內,此軟體非常好用.
(繼續閱讀...)
文章標籤

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

  • 個人分類:Program
▲top
  • 6月 02 週一 200817:12
  • [程式]都是無障礙的陰謀!?

在文章的開頭先說:本文的重點是  JQUERY & MOOTOOLS  
話說現在的日子就是把CASE給KO。而因為我和刀哥希望這些網站可以經過無障礙的規範以及往W3C的趨勢走。
(繼續閱讀...)
文章標籤

andyyu0920 發表在 痞客邦 留言(9) 人氣(283)

  • 個人分類:Program
▲top
12»

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追蹤貼紙