濮阳杆衣贸易有限公司

主頁(yè) > 知識(shí)庫(kù) > ASP.NET筆記之 Repeater的使用

ASP.NET筆記之 Repeater的使用

熱門(mén)標(biāo)簽:廈門(mén)四川外呼系統(tǒng) 內(nèi)蒙古智能電銷(xiāo)機(jī)器人哪家強(qiáng) 百度地圖標(biāo)注點(diǎn)擊事件 怎樣在地圖標(biāo)注消火栓圖形 濟(jì)源人工智能電話(huà)機(jī)器人價(jià)格 泰州手機(jī)外呼系統(tǒng)軟件 杭州智能電話(huà)機(jī)器人 山東防封電銷(xiāo)卡辦理套餐 地圖標(biāo)注位置多的錢(qián)

1、數(shù)據(jù)綁定
combox-->BingdSource-->ObjectDataSource

//連接數(shù)據(jù)庫(kù)
**后臺(tái)代碼:

T_UserTableAdapter adpter=T_UserTableAdpter();
adpater.調(diào)用T_User表的自定義方法

            

//設(shè)置初始數(shù)據(jù):
AppenddateBource="true";

 


2、Repeater 動(dòng)態(tài)顯示數(shù)據(jù)表中所有數(shù)據(jù):(相當(dāng)于一個(gè)for語(yǔ)句我覺(jué)得)

#代表綁定數(shù)據(jù)
(1、模板:ItemTemplate>主鍵:%#Eval("Id")%> /ItemTemplate>
(2、其他模板(隔行顯示):AlternatingTemplate>/AlternatingTemplate>
(3、還有頭部尾部模板HeaderItemplate>還有FooterItemplate>

(4、可以在%aaa(Eval("a")) %>中調(diào)用服務(wù)端函數(shù)
protected string aaa(object url){
return ResolveClientUrl("/../"+url);
}

(5、常見(jiàn)的類(lèi)型語(yǔ)句:

**1:e.Item.ItemType==ListItemType.Item||e.Item.ItemType==ListItemType.AlternatingItem 
指觸發(fā)的類(lèi)型為DadaList中的基本行或內(nèi)容行 :用來(lái)判斷項(xiàng)是控件內(nèi)容中的項(xiàng)或交插項(xiàng)

**2:e.Item.ItemType == ListItemType.Header 
指觸發(fā)的類(lèi)型為DadaList中的標(biāo)題行的內(nèi)容:用來(lái)判斷項(xiàng)是不是控件的表頭

**3搜索資料:

ListItemType 枚舉    [C#]請(qǐng)參見(jiàn)
System.Web.UI.WebControls 命名空間 | DataGridItem.ItemType | DataListItem.ItemType | RepeaterItem.ItemType 
命名空間: System.Web.UI.WebControls

ListItemType    枚舉表示可以包含在列表控件中的不同項(xiàng),例如 DataGrid、DataList 和 Repeater。典型的列表控件由包含此枚舉所表示的元素的單元格組成。

成員
成員名稱(chēng)            說(shuō)明 
AlternatingItem    交替(從零開(kāi)始的偶數(shù)索引)單元格中的項(xiàng)。它是數(shù)據(jù)綁定的。 
EditItem     列表控件中當(dāng)前處于編輯模式的項(xiàng)。它是數(shù)據(jù)綁定的。 
Footer     列表控件的頁(yè)腳。它不是數(shù)據(jù)綁定的。 
Header     列表控件的頁(yè)眉。它不是數(shù)據(jù)綁定的。 
Item    列表控件中的項(xiàng)。它是數(shù)據(jù)綁定的。 
Pager     頁(yè)導(dǎo)航,顯示定位到與 DataGrid 控件關(guān)聯(lián)的不同頁(yè)的控件。它不是數(shù)據(jù)綁定的。 
SelectedItem     列表控件中的選定項(xiàng)。它是數(shù)據(jù)綁定的。 
Separator    列表控件中項(xiàng)之間的分隔符。它不是數(shù)據(jù)綁定的。

 3、Repeater事件之ItemDataBound事件

(1、OnItemDataBound事件(綁定中獲取同一行相關(guān)信息)

DataRowView MyRow= (DataRowView)e.Item.DataItem;
MyRow["這里是相關(guān)字段名稱(chēng)"]

(2、后臺(tái)代碼:獲取數(shù)據(jù)庫(kù)表中的列

//取出綁定行的信息
DataRowView view=(DataRowView)e.Item.DataItem;
//強(qiáng)連接
var row=(項(xiàng)目名稱(chēng)/文件夾名/DAL/DataSetPersons/T_PersonsRow)view.Row;

(3、后臺(tái)代碼:母版中的ID不能直接取

//獲得ID
TextBox txtId=(TextBox)e.Item.FindControl("id");
//根據(jù)ID進(jìn)行操作
txtId.BackColor=Color.Red;

(4、aspx中:href='%#Eval("URL")%>'

這樣在瀏覽器中點(diǎn)擊是不會(huì)到指定頁(yè)面的,應(yīng)當(dāng)改成
href='http://%#Eval("URL")%>'

(5、aspx中:支持格式
     %#Eval("Date","yyyy-mm-dd")%>

 4、Repeater事件之ItemCommand事件

** e.CommandName 名字
** e.CommandArgument 參數(shù)

**后臺(tái)代碼獲取前臺(tái)傳過(guò)來(lái)的參數(shù)例如ID: long id=Convert.ToInt64(e.CommandArgument);

**后臺(tái)代碼:Repeater.DataBing//強(qiáng)制刷新數(shù)據(jù)

 

(1、OnClientClick="return confirm("您真的要操作嗎?");"

(2、看aspx中id的類(lèi)型,可以先頂一個(gè)id,然后在aspx.cs中查看它是什么類(lèi)型
//如下用法:
HtmlTableRow tr=(HtmlTableRow)e.Item.FindControl("id");
//自定義屬性::css具體的實(shí)現(xiàn)在頁(yè)面中,后臺(tái)只是引用
**后臺(tái)代碼:tr.Attributes["class"]="css中的.id";

(3、拋出錯(cuò)誤: throw new Exception("自己定義的錯(cuò)誤類(lèi)型");

5、實(shí)例:

move_pic.aspx

復(fù)制代碼 代碼如下:

%@ Page Language="C#" AutoEventWireup="true" CodeBehind="move_pic.aspx.cs" Inherits="Move_Pic.move_pic" %>

 !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 id="Head1" runat="server">
     title>/title>
     script src="Scripts/jquery-1.4.1.js" type="text/javascript">/script>

 /head>

 body>
     form id="form1" runat="server">
     div>

         asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
             DeleteMethod="Delete" InsertMethod="Insert"
             OldValuesParameterFormatString="original_{0}" SelectMethod="GetData"
             TypeName="Move_Pic.DAL.DataSet1TableAdapters.T_userInfoTableAdapter"
             UpdateMethod="Update">
             DeleteParameters>
                 asp:Parameter Name="Original_sUserName" Type="String" />
             /DeleteParameters>
             InsertParameters>
                 asp:Parameter Name="sUserName" Type="String" />
                 asp:Parameter Name="sPassWord" Type="String" />
                 asp:Parameter Name="Email" Type="String" />
                 asp:Parameter Name="Age" Type="Int32" />
                 asp:Parameter Name="Pic_url" Type="String" />
             /InsertParameters>
             UpdateParameters>
                 asp:Parameter Name="sPassWord" Type="String" />
                 asp:Parameter Name="Email" Type="String" />
                 asp:Parameter Name="Age" Type="Int32" />
                 asp:Parameter Name="Pic_url" Type="String" />
                 asp:Parameter Name="Original_sUserName" Type="String" />
             /UpdateParameters>
         /asp:ObjectDataSource>

     asp:Repeater ID="Repeater1" runat="server" DataSourceID="ObjectDataSource1">
       HeaderTemplate>歡迎選購(gòu)table id="tableId">tr>/HeaderTemplate>
       ItemTemplate>td>
         img a1='%#Eval("sUserName")%>' a2='%#Eval("Age") %>'width="100",
             height="150" src='image/%#Eval("Pic_url") %>' />/td>
       /ItemTemplate>
       FooterTemplate>/tr>/table>歡迎下次光臨/FooterTemplate>
     /asp:Repeater>

     script type="text/javascript">
         /*$("img").mousemove(function (e) {
             $("#sUserName").text($(this).attr("a1"));
             $("#Age").text($(this).attr("a2"));
             $("#divNone").css("top", e.pageY).css("left", e.pageX).show("slow");
         });*/
         //動(dòng)態(tài)增長(zhǎng)
       /* $(function () {
             $("#img").click(function () {
                 //$(this).animate({ "width": "+=300", "height": "+=300" });
                 $(this).animate({"width":"300","height":"300"});
                 //$(this).attr("width", "300").attr("height", "300");
             });
         });*/
         $("#tableId img").mouseenter(function () {
             $(this).animate({ "width": "300", "height": "300" },"slow");
             //$(this).siblings().animate({ "width": "150", "height": "300" });
             //將自己排除在外
             $("#tableId img").not($(this)).animate({ "width": "100", "height": "150" }, "slow");
         });
     /script>

     /div>
     div style="display:none"  id="divNone">
        p>姓名:span id="sUserName">/span>/p>
        p>年齡:span id="Age">/span>/p>
     /div>

     /form>
 /body>

 /html>

數(shù)據(jù)庫(kù)表設(shè)計(jì)如下:

您可能感興趣的文章:
  • ASP.NET repeater添加序號(hào)列的方法
  • asp.net Repeater取得CheckBox選中的某行某個(gè)值的c#寫(xiě)法
  • asp.net repeater手寫(xiě)分頁(yè)實(shí)例代碼
  • asp.net Repeater之非常好的數(shù)據(jù)分頁(yè)
  • asp.net中讓Repeater和GridView支持DataPager分頁(yè)
  • asp.net Repeater 數(shù)據(jù)綁定的具體實(shí)現(xiàn)(圖文詳解)
  • asp.net 遍歷repeater中的控件的幾種方式
  • asp.net下Repeater使用 AspNetPager分頁(yè)控件
  • asp.net repeater實(shí)現(xiàn)批量刪除
  • asp.net Repeater控件的說(shuō)明及詳細(xì)介紹及使用方法
  • asp.net Repeater 數(shù)據(jù)綁定代碼
  • JQuery實(shí)現(xiàn)Repeater無(wú)刷新批量刪除(附后臺(tái)asp.net源碼)
  • 決定何時(shí)使用 DataGrid、DataList 或 Repeater(ASP.NET 技術(shù)文章)
  • asp.net DataList與Repeater用法區(qū)別
  • 詳解ASP.NET數(shù)據(jù)綁定操作中Repeater控件的用法

標(biāo)簽:百色 洛陽(yáng) 朔州 新鄉(xiāng) 臺(tái)州 周口 朝陽(yáng) 喀什

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《ASP.NET筆記之 Repeater的使用》,本文關(guān)鍵詞  ASP.NET,筆記,之,Repeater,的,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問(wèn)題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無(wú)關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《ASP.NET筆記之 Repeater的使用》相關(guān)的同類(lèi)信息!
  • 本頁(yè)收集關(guān)于ASP.NET筆記之 Repeater的使用的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    楚雄市| 固阳县| 贵南县| 玉田县| 子长县| 神木县| 大同市| 荥阳市| 迭部县| 怀宁县| 和静县| 卫辉市| 怀集县| 拉萨市| 迭部县| 花莲县| 扬中市| 临高县| 华坪县| 镇安县| 蕉岭县| 吉安县| 九台市| 宁化县| 淳安县| 禹州市| 昌乐县| 望都县| 普安县| 祁阳县| 武安市| 九龙坡区| 阜阳市| 原平市| 丰都县| 襄汾县| 堆龙德庆县| 成都市| 扶沟县| 松潘县| 蒙阴县|