国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

ASP.NET WebForm中asp:Repeater和UI:Grid數(shù)據(jù)為空時如何顯示表頭?

這篇具有很好參考價值的文章主要介紹了ASP.NET WebForm中asp:Repeater和UI:Grid數(shù)據(jù)為空時如何顯示表頭?。希望對大家有所幫助。如果存在錯誤或未考慮完全的地方,請大家不吝賜教,您也可以點(diǎn)擊"舉報違法"按鈕提交疑問。

一、asp:Repeater

Repeater 控件用于顯示被綁定在該控件上的項(xiàng)目的重復(fù)列表。Repeater 控件可被綁定到數(shù)據(jù)庫表、XML 文件或者其他項(xiàng)目列表。

?

1.1-前臺頁面代碼

 <asp:Repeater ID="ImageTypeListNew" runat="server" OnItemCommand="ImageTypeListNew_ItemCommand">
                    <HeaderTemplate>
                        <table cellspacing="0" border="0" id="ctl00_contentHolder_ImageTypeList" class="table table-striped">
                            <tbody>
                                <tr>
                                    <th>分類名稱</th>
                                    <th>圖片數(shù)</th>
                                    <th>排序</th>
                                    <th style="width: 20%;">操作</th>
                                </tr>
                    </HeaderTemplate>
                    <ItemTemplate>
                        <tr>
                            <td>
                                <asp:HiddenField ID="hfItemIndex" runat="server" Value='<%#Container.ItemIndex %>' />
                                <asp:HiddenField ID="hfCategoryId" runat="server" Value='<%#Eval("CategoryId") %>' />
                                <Hi:HtmlDecodeTextBox ID="ImageTypeName" runat="server" Text='<%# Bind("CategoryName") %>' CssClass="forminput form-control" Visible='<%#Eval("CategoryId").ToString()!="0" %>' />
                                <asp:Label ID="ltlTypeName" runat="server" Text='<%# Bind("CategoryName") %>' Visible='<%#Eval("CategoryId").ToString()=="0" %>'></asp:Label>
                            </td>
                            <td>
                                <%#Eval("VideoCounts") %>
                            </td>
                            <td>
                                <asp:Label ID="Label1" runat="server" Text='<%# Bind("DisplaySequence") %>' Visible='<%#Eval("CategoryId").ToString()=="0" %>'></asp:Label>
                               <asp:TextBox ID="txtDisplaySequence" runat="server" Button="btnSearchButton" CssClass="forminput form-control" value='<%# Eval("DisplaySequence") %>' Visible='<%#Eval("CategoryId").ToString()!="0" %>' onkeyup="this.value=this.value.replace(/\D/g,'')"  style="width: 60px;" onafterpaste="this.value=this.value.replace(/\D/g,'')" />
                            </td>
                            <td><span class="submit_shanchu">
                                <Hi:ImageLinkButton runat="server" ID="lkbtnDelete" CommandName="Delete" IsShow="true" Text="刪除" Visible='<%#Eval("CategoryId").ToString()!="0" %>'/></span></td>
                        </tr>
                    </ItemTemplate>
                    <FooterTemplate></tbody></table></FooterTemplate>
                </asp:Repeater>

?

?1.2-后臺頁面代碼(核心)

ASP.NET WebForm中asp:Repeater和UI:Grid數(shù)據(jù)為空時如何顯示表頭?

?代碼示例:

DataTable videoCategories = GalleryHelper.GetVideoCategories(0);
DataRow row = videoCategories.NewRow();

//如果數(shù)據(jù)為空,設(shè)置第一行數(shù)據(jù)
row["CategoryId"] = "0";
row["CategoryName"] = "默認(rèn)分類";
row["DisplaySequence"] = "0";
row["VideoCounts"] = "0";
videoCategories.Rows.InsertAt(row, 0);

this.ImageTypeListNew.DataSource = videoCategories;
this.ImageTypeListNew.DataBind();

?

1.3-使用方法

在頁面加載時【Page_Load】可調(diào)用,以及刪除/排序/編輯等場景也可調(diào)用。

ASP.NET WebForm中asp:Repeater和UI:Grid數(shù)據(jù)為空時如何顯示表頭?

?

二、UI:Grid/GridView

?顯示表格數(shù)據(jù)是軟件開發(fā)中的一個周期性任務(wù)。ASP.NET 提供了許多工具來在網(wǎng)格中顯示表格數(shù)據(jù),例如 GridView 控件。通過使用 GridView 控件,您可以顯示、編輯和刪除多種不同的數(shù)據(jù)源(例如數(shù)據(jù)庫、XML 文件和公開數(shù)據(jù)的業(yè)務(wù)對象)中的數(shù)據(jù)。

1.1-前臺頁面代碼

            <UI:Grid ID="grdTopCategries" DataKeyNames="CategoryId" runat="server" ShowHeader="true" AutoGenerateColumns="false" CssClass="table table-striped" GridLines="None" Width="100%">
                <Columns>
                    <asp:TemplateField HeaderText="分類名稱">
                        <ItemTemplate>
                            <span class="icon" categoryid='<%# Eval("CategoryId") %>' parentid='<%# Eval("ParentCategoryId") %>' id="spShowImage" runat="server">
                                <img src="../images/jian.gif" width="24" height="24" /></span>
                            <span class="Name" id="spCategoryName"><a href='<%# "/product_detail/"+Eval("CategoryId")%>' target="_blank">
                                <asp:Literal ID="lblCategoryName" runat="server" /></a></span>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:BoundField HeaderText="URL重寫名稱" DataField="RewriteName" />
                    <asp:TemplateField HeaderText="排序">
                        <ItemTemplate>
                            <asp:TextBox ID="txtSequence" CssClass="form-control" runat="server" Text='<%# Eval("DisplaySequence") %>' Width="80px" />
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="操作" HeaderStyle-CssClass="td_left td_right_fff">
                        <ItemTemplate>
                            <div class="operation">
                                <span><a href="javascript:ShowRemoveProduct(<%#Eval("CategoryId") %>)">轉(zhuǎn)移商品</a></span>
                                  <span><span><a href="javascript:void(0);" onclick="javascript:CollectionCategory('<%# "EditReleteCategory.aspx?ParentCategoryId="+Eval("ParentCategoryId") + "&CategoryId="+Eval("CategoryId")%>')">相關(guān)課程</a></span></span>
                                <span>
                                    <asp:HyperLink ID="lkEdit" runat="server" Text="編輯" NavigateUrl='<%# "EditActivityCategory.aspx?CategoryId="+Eval("CategoryId")%>'></asp:HyperLink>
                                </span>
                            </div>
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
            </UI:Grid>

?

?1.2-后臺頁面代碼(核心)

ASP.NET WebForm中asp:Repeater和UI:Grid數(shù)據(jù)為空時如何顯示表頭?

?

?代碼示例:

 DataTable dt = new DataTable();
            if (inviteCodeList.TotalRecords == 0)
            {
                dt.Columns.Add("SaleId");
                dt.Columns.Add("UserId");
                dt.Columns.Add("TransactionDate");
                dt.Columns.Add("IncomeType");
                dt.Columns.Add("TransactionNo");
                dt.Columns.Add("TransactionType");
                dt.Columns.Add("RefundId");
                dt.Columns.Add("SaleName");
                dt.Columns.Add("UserName");
                dt.Columns.Add("OrderType");
                dt.Columns.Add("PaymentType");
                dt.Columns.Add("DeliverPrincipal");
                dt.Columns.Add("CommissionRate");
                dt.Columns.Add("Tax");
                dt.Columns.Add("DeliverIncome");
                dt.Columns.Add("ApprovedStatus");
                dt.Columns.Add("Reason");
                dt.Columns.Add("SettlementId");
                dt.Columns.Add("Amount");
                dt.Columns.Add("ApprovedStatusId");

                if (dt.Rows.Count == 0)
                {
                    dt.Rows.Add(dt.NewRow());
                }
                this.grdSaleInviteCode.DataSource = dt;
                this.grdSaleInviteCode.DataBind();
            }

?

原文鏈接:https://www.cnblogs.com/kimiliucn/p/17589737.html文章來源地址http://www.zghlxwxcb.cn/news/detail-618993.html

到了這里,關(guān)于ASP.NET WebForm中asp:Repeater和UI:Grid數(shù)據(jù)為空時如何顯示表頭?的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實(shí)不符,請點(diǎn)擊違法舉報進(jìn)行投訴反饋,一經(jīng)查實(shí),立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

  • 基于Vue2.0仿Element UI的el-tooltip實(shí)現(xiàn)一個氣泡框組件,支持多數(shù)據(jù)類型的顯示和內(nèi)容為空時不顯示氣泡框

    基于Vue2.0仿Element UI的el-tooltip實(shí)現(xiàn)一個氣泡框組件,支持多數(shù)據(jù)類型的顯示和內(nèi)容為空時不顯示氣泡框

    場景:因?yàn)橛袀€需求就是鼠標(biāo)經(jīng)過可多選的 el-select 選擇器時,需要有個氣泡框顯示已選的內(nèi)容,其實(shí) el-tooltip 氣泡框可以滿足需求,就是用 el-tooltip 氣泡框來包裹 el-select 選擇器,但是當(dāng)選擇器一個也沒選中,即內(nèi)容為空時不應(yīng)該也顯示氣泡框,有點(diǎn)影響美觀。應(yīng)該就是若內(nèi)

    2024年02月13日
    瀏覽(28)
  • 【ASP.NET MVC】數(shù)據(jù)庫訪問(5)

    【ASP.NET MVC】數(shù)據(jù)庫訪問(5)

    對象關(guān)系映射(Object Relational Mapping,簡稱ORM)模式是一種為了解決面向?qū)ο笈c關(guān)系數(shù)據(jù)庫存在的互不匹配的現(xiàn)象的技術(shù) 。? 以上是官話,個人理解: 1、解決問題:數(shù)據(jù)庫的訪問 2、如何解決:數(shù)據(jù)庫由表、記錄?組成? ? ? -》? ? 把表映射成面向?qū)ο蟮念? ?,記錄則是對

    2024年02月14日
    瀏覽(23)
  • ASP.NET之 用Mysql驅(qū)動連接數(shù)據(jù)庫

    ASP.NET之 用Mysql驅(qū)動連接數(shù)據(jù)庫

    前言:上一節(jié)已經(jīng)用VisualStudio2019成功創(chuàng)建和運(yùn)行了ASP項(xiàng)目( https://mp.csdn.net/mp_blog/creation/editor/129413215 ),下面將進(jìn)行數(shù)據(jù)庫的連接 一,下載驅(qū)動庫,根JSP一樣需要一個Mysql驅(qū)動包來支持.NET語言。官網(wǎng)下載鏈接: https://www.mysql.com/products/connector/ ? 二,安裝驅(qū)動包? 選擇自定義

    2024年02月02日
    瀏覽(27)
  • ASP.NET指定變量數(shù)據(jù)類型,速度提高了100倍

    ASP.NET指定變量數(shù)據(jù)類型,速度提高了100倍由自動編程人工智能?發(fā)表在專區(qū) 10億次求余數(shù)為0的計算: ASP運(yùn)行速度130秒左右 \\\' ASP.NET Dim i, c, max \\\'如果不指定數(shù)據(jù)類型,運(yùn)行要120秒左右 Dim i, c, max As Integer \\\'指定數(shù)據(jù)類型,運(yùn)行速度2秒 下面是ASP.NET代碼: 強(qiáng)類型,指定變量類型 測

    2024年02月12日
    瀏覽(15)
  • ASP.NET連接數(shù)據(jù)庫(SQL Server)的操作

    ASP.NET連接數(shù)據(jù)庫(SQL Server)的操作

    1.創(chuàng)建好項(xiàng)目后在我們的Web.config里面連接SQL Server數(shù)據(jù)庫 ?2.寫入代碼 appSettings add key=\\\"conStr\\\" value=\\\"Data Source=localhost;Initial Catalog=s;Integrated Security=True;\\\" / /appSettings conStr是字段名字,后面連接需要,localhost是本地地址的意思,s是數(shù)據(jù)庫中的表名。 3.選中shujuku練習(xí)右擊,選擇添加,

    2023年04月08日
    瀏覽(25)
  • ASP.NET Core MVC 從入門到精通之?dāng)?shù)據(jù)庫

    ASP.NET Core MVC 從入門到精通之?dāng)?shù)據(jù)庫

    隨著技術(shù)的發(fā)展,ASP.NET Core MVC也推出了好長時間,經(jīng)過不斷的版本更新迭代,已經(jīng)越來越完善,本系列文章主要講解ASP.NET Core MVC開發(fā)B/S系統(tǒng)過程中所涉及到的相關(guān)內(nèi)容,適用于初學(xué)者,在校畢業(yè)生,或其他想從事ASP.NET Core MVC 系統(tǒng)開發(fā)的人員。 經(jīng)過前幾篇文章的講解,初步

    2023年04月27日
    瀏覽(25)
  • 安全機(jī)密管理:Asp.Net Core中的本地敏感數(shù)據(jù)保護(hù)技巧

    安全機(jī)密管理:Asp.Net Core中的本地敏感數(shù)據(jù)保護(hù)技巧

    在我們開發(fā)過程中基本上不可或缺的用到一些敏感機(jī)密數(shù)據(jù),比如 SQL 服務(wù)器的連接串或者是 OAuth2 的 Secret 等,這些敏感數(shù)據(jù)在代碼中是不太安全的,我們不應(yīng)該在源代碼中存儲密碼和其他的敏感數(shù)據(jù),一種推薦的方式是通過 Asp.Net Core 的 機(jī)密管理器 。 在 ASP.NET Core 中,機(jī)密

    2024年04月25日
    瀏覽(27)
  • 【ASP.NET Core 基礎(chǔ)知識】--MVC框架--Models和數(shù)據(jù)綁定

    Models和數(shù)據(jù)綁定在ASP.NET Core MVC中扮演著關(guān)鍵的角色,對于構(gòu)建強(qiáng)大、靈活和可維護(hù)的Web應(yīng)用程序至關(guān)重要。這一節(jié)我們就來講一下。 一、Models 1.1 Models的定義和作用 在ASP.NET Core MVC中,Model是應(yīng)用程序中用于表示數(shù)據(jù)結(jié)構(gòu)和業(yè)務(wù)邏輯的一種抽象。Models充當(dāng)了MVC(Model-View-Contr

    2024年01月23日
    瀏覽(94)
  • ASP.NET WEB API通過SugarSql連接MySQL數(shù)據(jù)庫

    ASP.NET WEB API通過SugarSql連接MySQL數(shù)據(jù)庫

    注意:VS2022企業(yè)版可以,社區(qū)版可能存在問題。實(shí)體名稱和字段和數(shù)據(jù)庫中的要一致。 1、創(chuàng)建項(xiàng)目,安裝SqlSugarCore、Pomelo.EntityFrameworkCore.MySql插件 2、文件結(jié)構(gòu) 2、appsettings.json { “Logging”: { “LogLevel”: { “Default”: “Information”, “Microsoft.AspNetCore”: “Warning” } }, “Allowed

    2024年02月12日
    瀏覽(29)
  • 【ASP.NET】ASP.NET框架概述

    【ASP.NET】ASP.NET框架概述

    ?? 作者:@哈桑c(CSDN平臺) ?? 專欄:C#/.NET系列文章 序號 系列文章 0 【ASP.NET】手把手創(chuàng)建一個ASP.NET項(xiàng)目以及MVC模式的介紹 本文是 ASP.NET 框架的概述,相信看完本文之后大家就會對 ASP.NET 框架有一個初步的認(rèn)識。 ASP.NET 是微軟在2000年發(fā)布的一個免費(fèi)的 Web 框架,可以使用

    2024年02月04日
    瀏覽(21)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包