Telerik RadGrid Demo

List Page

Html code:

<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Videos.aspx.vb" Inherits="AwcWeb.Videos" %>

<%@ Register Assembly="AspNetPager" Namespace="Wuqi.Webdiyer" TagPrefix="webdiyer" %>
<%@ Register Src="LeftControl1.ascx" TagName="LeftControl1" TagPrefix="uc1" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<!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>
    <link href="css/Global.css" rel="stylesheet" type="text/css" />
    <script src="Scripts/RadCommon.js" type="text/javascript"></script>
    <style>
        ul#nav li a#nav03
        {
            background: #fff;
            color: #000;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
        <Scripts>
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js">
            </asp:ScriptReference>
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js">
            </asp:ScriptReference>
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js">
            </asp:ScriptReference>
        </Scripts>
    </telerik:RadScriptManager>
    <div class="header">
        <div class="roxvell_logo">
            <img width="191" height="24" style="margin-top: 35px; float: right;" src="images/logo.png">
        </div>
    </div>
    <div style="width: 1024px; height: 720px; margin: 0 auto; overflow: hidden;">
        <uc1:LeftControl1 ID="leftControl1" runat="server" />
        <div style="width: 874px; height: 720px; float: left;">
            <telerik:RadMenu ID="RadMenu1" runat="server" Skin="Default" OnClientItemClicked="OnClientItemClicked"
                Width="100%">
                <CollapseAnimation Duration="200" Type="OutQuint" />
                <Items>
                    <telerik:RadMenuItem runat="server" Text="新增" Style="cursor: pointer;" Value="New" />
                    <telerik:RadMenuItem runat="server" Text="編輯" Style="cursor: pointer;" Value="Edit" />
                    <telerik:RadMenuItem runat="server" Text="刪除" Style="cursor: pointer;" Value="Del" />
                </Items>
            </telerik:RadMenu>
            <div style="width: 100%; height: 664px; overflow: hidden;">
                <telerik:RadGrid ID="radGrid1" runat="server" Skin="Default" AutoGenerateColumns="False"
                    AllowMultiRowSelection="false" GridLines="None" PageSize="7" AllowPaging="True"
                    Height="664px">
                    <MasterTableView ClientDataKeyNames="VideoID" DataKeyNames="VideoID">
                        <NoRecordsTemplate>
                            <h4 style="color: #336699; font-weight: bold; font-size: 14px; height: 40px; line-height: 40px;
                                width: 100%; text-align: center;">
                                暫無數據.</h4>
                        </NoRecordsTemplate>
                        <Columns>
                            <telerik:GridTemplateColumn HeaderText="" UniqueName="Picture">
                                <ItemTemplate>
                                    <table cellpadding="0" cellspacing="0" border="0" style="width: 70px; height: 66px;">
                                        <tr valign="middle" align="center">
                                            <td valign="middle" align="center">
                                                <asp:Image ID="imgPic" runat="server" />
                                            </td>
                                        </tr>
                                    </table>
                                </ItemTemplate>
                                <HeaderStyle HorizontalAlign="Center" Width="10%" Height="66px" />
                                <ItemStyle HorizontalAlign="Center" />
                            </telerik:GridTemplateColumn>
                            <telerik:GridBoundColumn HeaderText="繁體標題" DataField="Title_tc" UniqueName="Title_tc">
                                <HeaderStyle HorizontalAlign="Center" Width="20%" />
                                <ItemStyle HorizontalAlign="Center" />
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn HeaderText="簡體標題" DataField="Title_sc" UniqueName="Title_sc">
                                <HeaderStyle HorizontalAlign="Center" Width="20%" />
                                <ItemStyle HorizontalAlign="Center" />
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn HeaderText="英文標題" DataField="Title_en" UniqueName="Title_en">
                                <HeaderStyle HorizontalAlign="Center" Width="20%" />
                                <ItemStyle HorizontalAlign="Center" />
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn HeaderText="日文標題" DataField="Title_jp" UniqueName="Title_jp">
                                <HeaderStyle HorizontalAlign="Center" Width="20%" />
                                <ItemStyle HorizontalAlign="Center" />
                            </telerik:GridBoundColumn>
                            <telerik:GridTemplateColumn HeaderText="" UniqueName="">
                                <ItemTemplate>
                                    <asp:Button ID="btnPublish" runat="server" Text="發佈" CommandName="Publish" CommandArgument=‘<%#Eval("VideoID") %>‘
                                        OnClientClick="if(!confirm(‘是否發佈該視頻?‘)) return false;" Style="width: 66px;" />
                                    <asp:Button ID="btnCancelPublish" runat="server" Text="取消發佈" CommandName="CancelPublish"
                                        Style="width: 66px;" CommandArgument=‘<%#Eval("VideoID") %>‘ OnClientClick="if(!confirm(‘該視頻是否取消發佈?‘)) return false;" />
                                </ItemTemplate>
                                <HeaderStyle HorizontalAlign="Center" Width="10%" />
                                <ItemStyle HorizontalAlign="Center" />
                            </telerik:GridTemplateColumn>
                        </Columns>
                    </MasterTableView>
                    <PagerStyle Font-Bold="False" Font-Italic="False" Font-Overline="False" Font-Strikeout="False"
                        Font-Underline="False" ForeColor="#336699" Mode="NumericPages" Wrap="True" />
                    <SelectedItemStyle ForeColor="GreenYellow" />
                    <ClientSettings AllowColumnsReorder="True" ReorderColumnsOnClient="True">
                        <Selecting AllowRowSelect="True" />
                        <Scrolling AllowScroll="true" UseStaticHeaders="true" />
                        <ClientEvents OnRowDblClick="RowDblClick" />
                    </ClientSettings>
                </telerik:RadGrid>
            </div>
            <div style="text-align: right; width: 100%; clear: both; border-top: 1px solid #828282;
                padding-top: 8px;">
                <div style="width: 50px; height: 20px; float: right;">
                </div>
                <webdiyer:AspNetPager ID="AspNetPager1" runat="server" CurrentPageButtonStyle="FONT-SIZE: 12px;color:red"
                    FirstPageText="" LastPageText="" NextPageText="下一頁" NumericButtonCount="5" PrevPageText="上一頁"
                    PrevNextButtonsStyle="font-size:12px" ShowPageIndexBox="never">
                </webdiyer:AspNetPager>
            </div>
        </div>
    </div>
    <div class="footer" style="clear: both;">
    </div>
    <telerik:RadAjaxManager runat="server" ID="RadAjaxManager1">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="RadAjaxManager1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadMenu1" />
                    <telerik:AjaxUpdatedControl ControlID="AspNetPager1" />
                    <telerik:AjaxUpdatedControl ControlID="radGrid1" LoadingPanelID="RadAjaxLoadingPanel1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="AspNetPager1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadMenu1" />
                    <telerik:AjaxUpdatedControl ControlID="AspNetPager1" />
                    <telerik:AjaxUpdatedControl ControlID="radGrid1" LoadingPanelID="RadAjaxLoadingPanel1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Width="330px"
        Height="100px">
        <img alt="Loading..." src=‘<%= RadAjaxLoadingPanel.GetWebResourceUrl(Page, "Telerik.Web.UI.Skins.Default.Ajax.loading.gif") %>‘
            style="border: 0px;" />
    </telerik:RadAjaxLoadingPanel>
    <telerik:RadWindowManager Style="z-index: 900001" ID="RadWindowManager1" runat="server"
        Behavior="Close" Modal="true" Skin="Default" VisibleStatusbar="false" ShowContentDuringLoad="false">
    </telerik:RadWindowManager>
    <telerik:RadCodeBlock runat="server" ID="CodeBlock1">
        <script type="text/javascript">
            var width = 716;
            var height = 380;

            function OnClientItemClicked(sender, args) {
                var itemValue = args.get_item().get_value();
                switch (itemValue) {
                    case "New":
                        InsertCommand();
                        break;
                    case "Edit":
                        UpdateCommand();
                        break;
                    case "Del":
                        MultiRowDel();
                        break;
                }
            }

            function MultiRowDel() {
                arrayArticleID = "";
                var items = $find("<%=radGrid1.ClientID %>").get_masterTableView().get_selectedItems();

                if (items.length <= 0) {
                    window.radalert(‘請先選擇一張視頻,再進行刪除操作 !‘, 330, 100, ‘資訊‘);
                    return false;
                }
                else {
                    window.radconfirm(‘確定要刪除該視頻嗎 ?‘, confirmCallBackFn, 330, 100, null, "刪除");
                }

            }

            function confirmCallBackFn(arg) {
                if (arg) {
                    $find("<%=RadAjaxManager1.ClientID %>").ajaxRequest("Delete#");
                }
            }

            function MultiRowDelFn(arg) {
                if (arg) {
                    $find("<%=RadAjaxManager1.ClientID %>").ajaxRequest("Delete#" + arrayArticleID)
                }
            }

            function InsertCommand() {
                var url = "VideoItem.aspx?EditMode=New";
                var title = "新增視頻";

                OpenWin(url, title, width, height, "EditWindow");
            }

            function UpdateCommand() {
                var grid = $find("<%=radGrid1.ClientID %>");
                var MasterTable = grid.get_masterTableView();
                var selectedItems = MasterTable.get_selectedItems();
                if (selectedItems.length > 0) {
                    var row = selectedItems[0];
                    var strselectid = row.getDataKeyValue("VideoID");
                    var url = "VideoItem.aspx?VideoID=" + strselectid + "&EditMode=Edit";
                    var title = "修改視頻";

                    OpenWin(url, title, width, height, "EditWindow");
                }
                else {
                    window.radalert(‘請先選擇一個視頻,再進行修改操作 !‘, 330, 100, ‘資訊‘);
                }
            }

            function refreshGrid(arg, EditType) {
                if (EditType == "1") {
                    if (arg == "succeed") {
                        $find("<%=RadAjaxManager1.ClientID %>").ajaxRequest("New#" + EditType);
                    }
                    else {
                        window.radalert(‘新增視頻失敗 !‘, 330, 100, ‘資訊‘);
                    }
                }
                else if (EditType == "2") {
                    if (arg == "succeed") {
                        $find("<%=RadAjaxManager1.ClientID %>").ajaxRequest("Edit#" + EditType);
                    }
                    else {
                        window.radalert(‘修改視頻失敗 !‘, 330, 100, ‘資訊‘);
                    }
                }
            }
            function RowDblClick(sender, eventArgs) {
                UpdateCommand();
            }
        </script>
    </telerik:RadCodeBlock>
    </form>
</body>
</html>

.net code:

Imports AWC.AndyVideosObj.AndyVideosObjEntry
Imports Telerik.Web.UI

Public Class Videos
    Inherits System.Web.UI.Page

    Private m_ocolAndyVideosObj As colAndyVideosObj
    Private Const intPageSize As Integer = 7

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not IsPostBack Then
            If Session.Item("UserID") Is Nothing Then
                Page.ClientScript.RegisterStartupScript(Me.GetType, "Message", "window.location.href=‘Login.aspx‘;", True)
            End If

            AspNetPager1.PageSize = intPageSize
            BindData(1)
        End If
    End Sub

    Protected Sub AspNetPager1_PageChanged(ByVal sender As Object, ByVal e As EventArgs) Handles AspNetPager1.PageChanged
        BindData(AspNetPager1.CurrentPageIndex)
    End Sub

    Sub BindData(ByVal pCurrentPage As Integer)
        m_ocolAndyVideosObj = Nothing
        Dim intCount As Integer = 0
        intCount = clsBllFactory.oAndyVideosObjBLL.GetAndyVideosRecordCount()
        If intCount > 0 Then
            m_ocolAndyVideosObj = clsBllFactory.oAndyVideosObjBLL.GetAndyVideosByPage(intPageSize, pCurrentPage)
            AspNetPager1.CurrentPageIndex = pCurrentPage
            AspNetPager1.RecordCount = intCount
            radGrid1.DataSource = m_ocolAndyVideosObj
            radGrid1.DataBind()
        Else
            AspNetPager1.RecordCount = 0
            radGrid1.DataSource = New colAndyVideosObj
            radGrid1.DataBind()
        End If
    End Sub

    Private Sub Grid_Product_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles radGrid1.ItemDataBound
        Dim oclsAndyVideosObj As clsAndyVideosObj = Nothing
        Dim imgPic As System.Web.UI.WebControls.Image
        Dim btnPublish, btnCancelPublish As System.Web.UI.WebControls.Button

        If e.Item.ItemType = GridItemType.Item Or e.Item.ItemType = GridItemType.AlternatingItem Then
            imgPic = CType(e.Item.FindControl("imgPic"), System.Web.UI.WebControls.Image)
            btnPublish = CType(e.Item.FindControl("btnPublish"), System.Web.UI.WebControls.Button)
            btnCancelPublish = CType(e.Item.FindControl("btnCancelPublish"), System.Web.UI.WebControls.Button)

            oclsAndyVideosObj = e.Item.DataItem
            If oclsAndyVideosObj IsNot Nothing Then
                SetSmallImageUrl(imgPic, Server, oclsAndyVideosObj.Photo, AndyVideoPath, NoPicture, 66, 66)

                If oclsAndyVideosObj.IsPublish Then
                    btnCancelPublish.Visible = True
                    btnPublish.Visible = False
                Else
                    btnCancelPublish.Visible = False
                    btnPublish.Visible = True
                End If
            End If
        End If
    End Sub

    Protected Sub RadAjaxManager1_AjaxRequest(ByVal sender As Object, ByVal e As Telerik.Web.UI.AjaxRequestEventArgs) Handles RadAjaxManager1.AjaxRequest
        Dim strCommand As String = Nothing
        Dim strVideoID As String
        Dim oclsAndyVideosObj As clsAndyVideosObj
        Dim intPage, selectindex As Integer

        strCommand = e.Argument.Substring(0, e.Argument.IndexOf("#"))
        strVideoID = e.Argument.Split("#")(1)
        Select Case strCommand
            Case "New"
                BindData(1)
                AspNetPager1.CurrentPageIndex = 0
                radGrid1.MasterTableView.CurrentPageIndex = 0
                radGrid1.SelectedIndexes.Clear()
                radGrid1.SelectedIndexes.Add(0)
            Case "Edit"
                selectindex = radGrid1.SelectedIndexes(0)
                BindData(AspNetPager1.CurrentPageIndex())
                radGrid1.SelectedIndexes.Clear()
                radGrid1.SelectedIndexes.Add(selectindex)
            Case "Delete"
                Dim oFile As String = ""
                Dim oFile2 As String = ""

                Dim ocolAndyVideosObj As colAndyVideosObj
                ocolAndyVideosObj = clsBllFactory.oAndyVideosObjBLL.GetAndyVideosByPage(intPageSize, AspNetPager1.CurrentPageIndex)

                If radGrid1.SelectedItems.Count <= 0 Then
                    Return
                End If

                For Each draggedItem As GridDataItem In radGrid1.SelectedItems
                    strVideoID = draggedItem.GetDataKeyValue("VideoID")
                    oclsAndyVideosObj = ocolAndyVideosObj.Item(strVideoID)
                    If oclsAndyVideosObj IsNot Nothing Then
                        oclsAndyVideosObj.IsDelete = True
                        oclsAndyVideosObj.Dirty = True

                        oFile = Server.MapPath(AndyVideoPath + oclsAndyVideosObj.Photo)
                        oFile2 = Server.MapPath(SmallAndyVideoPath + oclsAndyVideosObj.Photo)
                    End If
                Next

                If clsBllFactory.oAndyVideosObjBLL.ModifyAndyVideos(ocolAndyVideosObj, Nothing) = 1 Then
                    BindData(1)
                    AspNetPager1.CurrentPageIndex = 0
                    radGrid1.MasterTableView.CurrentPageIndex = 0
                    radGrid1.SelectedIndexes.Clear()
                    radGrid1.SelectedIndexes.Add(0)

                    If oFile.Length > 0 AndAlso IO.File.Exists(oFile) Then
                        IO.File.Delete(oFile)
                    End If

                    If oFile2.Length > 0 AndAlso IO.File.Exists(oFile2) Then
                        IO.File.Delete(oFile2)
                    End If
                Else
                    Me.RadAjaxManager1.Alert("操作失敗,請刷新后再試!")
                End If
        End Select
    End Sub

    Protected Sub radGrid1_ItemCommand(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles radGrid1.ItemCommand

        Try
            Dim strVideoID As String
            Dim oclsAndyVideosObj As clsAndyVideosObj

            If e.CommandName = "Publish" Then
                strVideoID = e.CommandArgument
                oclsAndyVideosObj = clsBllFactory.oAndyVideosObjBLL.GetAndyVideos(strVideoID, "")

                If oclsAndyVideosObj.IsPublish = True Then
                    Me.RadAjaxManager1.Alert("該視頻已經發佈。")
                    Exit Sub
                End If

                oclsAndyVideosObj.IsPublish = True
                oclsAndyVideosObj.Dirty = True

                If clsBllFactory.oAndyVideosObjBLL.UpdateAndyVideos(oclsAndyVideosObj, Nothing) = 1 Then
                    RefreshGrid()
                Else
                    Me.RadAjaxManager1.Alert("視頻發佈失敗。")
                End If
            ElseIf e.CommandName = "CancelPublish" Then
                strVideoID = e.CommandArgument
                oclsAndyVideosObj = clsBllFactory.oAndyVideosObjBLL.GetAndyVideos(strVideoID, "")

                If oclsAndyVideosObj.IsPublish = False Then
                    Me.RadAjaxManager1.Alert("該視頻已經取消發佈。")
                    Exit Sub
                End If

                oclsAndyVideosObj.IsPublish = False
                oclsAndyVideosObj.Dirty = True

                If clsBllFactory.oAndyVideosObjBLL.UpdateAndyVideos(oclsAndyVideosObj, Nothing) = 1 Then
                    RefreshGrid()
                Else
                    Me.RadAjaxManager1.Alert("視頻取消發佈失敗。")
                End If
            End If
        Catch ex As Exception
            Me.RadAjaxManager1.Alert("系統錯誤,請與我們聯繫。")
        End Try
    End Sub

    Private Sub RefreshGrid()
        Dim selectindex As Integer
        Try
            selectindex = radGrid1.SelectedIndexes(0)
            BindData(AspNetPager1.CurrentPageIndex())
            radGrid1.SelectedIndexes.Clear()
            radGrid1.SelectedIndexes.Add(selectindex)
        Catch ex As Exception
            BindData(AspNetPager1.CurrentPageIndex())
        End Try
    End Sub

End Class

Item Page

Html code :

<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="VideoItem.aspx.vb" Inherits="AwcWeb.VideoItem" %>

<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<!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">
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
    <title></title>
    <link href="css/Global.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="scripts/RadCommon.js"></script>
    <script type="text/javascript" src="scripts/ImageManger.js"></script>
    <script>
        function clear1() {
            document.getElementById("HfUrl").value = "";
            var img = document.getElementById("imgPhoto");
            img.src = "ImageManager/nophoto_s.jpg";
            img.style.width = "66px";
            img.style.height = "66px";

        }

    </script>
    <style>
        body
        {
            overflow: hidden;
        }
        #table2 tr td
        {
            text-align: left;
            height: 30px;
        }
        .alignRight
        {
            text-align: right !important;
        }
    </style>
</head>
<body>
    <form id="MyForm" runat="server">
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
    </telerik:RadScriptManager>
    <div style="width: 700px; clear: both; text-align: center;">
        <table id="table2" border="0" cellpadding="0" cellspacing="0" style="border: 0; width: 700px;">
            <tr>
                <td style="width: 100px; height: 10px; text-align: right;">
                </td>
                <td style="width: 250px;">
                </td>
                <td style="width: 100px; text-align: right;">
                </td>
                <td style="width: 250px;">
                </td>
            </tr>
            <tr>
                <td class="alignRight">
                    生效日期:
                </td>
                <td>
                    <telerik:RadDatePicker ID="tpStartDate" runat="server" Skin="Default" Calendar-EnableShadows="true"
                        DateInput-DateFormat="yyyy-MM-dd" DateInput-EmptyMessage="請選生效日期" Width="220"
                        CssClass="inputCSS" />
                    <span class="redCss">*</span>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="tpStartDate"
                        Display="Dynamic" ErrorMessage="" ValidationGroup="SubmitGroup" ForeColor="Red" />
                </td>
                <td class="alignRight">
                    圖片:
                </td>
                <td rowspan="4" style="height: 90px;">
                    <div id="izImgZoom1" class="ContentImg" style="overflow: hidden; width: 250px; height: 70px;
                        float: left;">
                        <table border="0" cellpadding="0" cellspacing="0" style="width: 66px; height: 66px;
                            float: left;">
                            <tr align="center" valign="middle">
                                <td align="center" valign="middle">
                                    <asp:Image ID="imgPhoto" runat="server" CssClass="imgSize" ImageUrl="ImageManager/nophoto_s.jpg" />
                                </td>
                            </tr>
                        </table>
                        <span style="line-height: 66px; margin-left: 5px; color: Red; font-size: 12px; float: left;">
                            建議圖片分辨率:308px * 154px </span>
                    </div>
                    <asp:HiddenField ID="HfUrl" runat="server" />
                    <div style="clear: both; width: 300px; height: 30px; overflow: hidden; padding-top: 10px;">
                        <telerik:RadUpload ID="RadUpload1" runat="server" ControlObjectsVisibility="ClearButtons"
                            Localization-Select="Browse" AllowedFileExtensions=".gif,.jpg,.bmp,.jpeg,.png"
                            InputSize="11" OverwriteExistingFiles="True" ReadOnlyFileInputs="True" MaxFileInputsCount="1"
                            Font-Overline="False" OnClientClearing="clear1">
                            <Localization Select="Browse" Clear="Clear" />
                        </telerik:RadUpload>
                    </div>
                </td>
            </tr>
            <tr>
                <td class="alignRight">
                    截止日期:
                </td>
                <td>
                    <telerik:RadDatePicker ID="tpExpireDate" runat="server" Skin="Default" Calendar-EnableShadows="true"
                        DateInput-DateFormat="yyyy-MM-dd" DateInput-EmptyMessage="請選截止日期" Width="220"
                        CssClass="inputCSS" />
                    <span class="redCss">*</span>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="tpExpireDate"
                        Display="Dynamic" ErrorMessage="" ValidationGroup="SubmitGroup" ForeColor="Red" />
                </td>
                <td class="alignRight">
                </td>
            </tr>
            <tr>
                <td class="alignRight">
                    發佈日期:
                </td>
                <td>
                    <telerik:RadDatePicker ID="tpPublishDate" runat="server" Skin="Default" Calendar-EnableShadows="true"
                        DateInput-DateFormat="yyyy-MM-dd" DateInput-EmptyMessage="請選發佈日期" Width="220"
                        CssClass="inputCSS" />
                    <span class="redCss">*</span>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="tpPublishDate"
                        Display="Dynamic" ErrorMessage="" ValidationGroup="SubmitGroup" ForeColor="Red" />
                </td>
                <td class="alignRight">
                </td>
            </tr>
            <tr>
                <td class="alignRight">
                    視頻類型:
                </td>
                <td>
                    <asp:DropDownList ID="ddlVideoType" runat="server" Width="100px">
                        <asp:ListItem Selected="True" Value="1">文件</asp:ListItem>
                        <asp:ListItem Value="2">視頻流</asp:ListItem>
                    </asp:DropDownList>
                </td>
                <td class="alignRight">
                </td>
            </tr>
            <tr>
                <td class="alignRight">
                    視頻連接:
                </td>
                <td colspan="3">
                    <asp:TextBox ID="txtVideo" runat="server" CssClass="inputCSS" Width="541px"></asp:TextBox>
                    <span class="redCss">*</span>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator8" runat="server" ControlToValidate="txtVideo"
                        Display="Dynamic" ErrorMessage="" ValidationGroup="SubmitGroup" ForeColor="Red" />
                </td>
            </tr>
            <tr>
                <td class="alignRight">
                    繁體標題:
                </td>
                <td>
                    <asp:TextBox ID="txtTitle_tc" runat="server" CssClass="inputCSS" Width="220px"></asp:TextBox>
                    <span class="redCss">*</span>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ControlToValidate="txtTitle_tc"
                        Display="Dynamic" ErrorMessage="" ValidationGroup="SubmitGroup" ForeColor="Red" />
                </td>
                <td class="alignRight">
                    簡體標題:
                </td>
                <td>
                    <asp:TextBox ID="txtTitle_sc" runat="server" CssClass="inputCSS" Width="220px"></asp:TextBox>
                    <span class="redCss">*</span>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" ControlToValidate="txtTitle_sc"
                        Display="Dynamic" ErrorMessage="" ValidationGroup="SubmitGroup" ForeColor="Red" />
                </td>
            </tr>
            <tr>
                <td class="alignRight">
                    英文標題:
                </td>
                <td>
                    <asp:TextBox ID="txtTitle_en" runat="server" CssClass="inputCSS" Width="220px"></asp:TextBox>
                    <span class="redCss">*</span>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server" ControlToValidate="txtTitle_en"
                        Display="Dynamic" ErrorMessage="" ValidationGroup="SubmitGroup" ForeColor="Red" />
                </td>
                <td class="alignRight">
                    日語標題:
                </td>
                <td>
                    <asp:TextBox ID="txtTitle_jp" runat="server" CssClass="inputCSS" Width="220px"></asp:TextBox>
                    <span class="redCss">*</span>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator7" runat="server" ControlToValidate="txtTitle_jp"
                        Display="Dynamic" ErrorMessage="" ValidationGroup="SubmitGroup" ForeColor="Red" />
                </td>
            </tr>
            <tr>
                <td class="alignRight">
                    备注:
                </td>
                <td colspan="3">
                    <asp:TextBox ID="txtRemark" runat="server" CssClass="inputCSS" Width="541px"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td colspan="4" style="height: auto; padding-top: 20px; text-align: center">
                    <asp:Button ID="btnSure" Text="確定" CssClass="buttonStyle btnCss2" ValidationGroup="SubmitGroup"
                        runat="server" />    
                    <input type="button" id="btnCancel" class="buttonStyle btnCss2" value="取消" />
                </td>
            </tr>
        </table>
    </div>
    </form>
</body>
</html>

.net code:

Imports AWC.AndyVideosObj.AndyVideosObjEntry
Imports Telerik.Web.UI
Imports System.Drawing

Partial Public Class VideoItem
    Inherits System.Web.UI.Page

    Public Property VideoID() As String
        Get
            If ViewState("VideoID") Is Nothing Then
                Return String.Empty
            End If
            Return ViewState("VideoID").ToString()
        End Get
        Set(ByVal value As String)
            ViewState("VideoID") = value
        End Set
    End Property

    Public Property EditMode() As String
        Get
            If ViewState("EditMode") Is Nothing Then
                Return String.Empty
            End If
            Return ViewState("EditMode").ToString()
        End Get
        Set(ByVal value As String)
            ViewState("EditMode") = value
        End Set
    End Property

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim oclsAndyVideosObj As clsAndyVideosObj
        If Session.Item("UserID") Is Nothing Then
            Page.ClientScript.RegisterStartupScript(Me.GetType, "Message", " CancelEdit();parent.window.location.href=‘Login.aspx‘;", True)
        End If

        If IsPostBack = False Then
            Dim strEditMode, strVideoID As String

            strEditMode = Request.QueryString("EditMode")
            If strEditMode IsNot Nothing Then
                EditMode = strEditMode
            Else
                Page.ClientScript.RegisterStartupScript(Me.GetType, "Message", "alert(‘參數錯誤!‘); CancelEdit();", True)
            End If

            If EditMode = "New" Then

            Else
                strVideoID = Request.QueryString("VideoID")
                If strVideoID IsNot Nothing Then
                    VideoID = strVideoID
                    oclsAndyVideosObj = clsBllFactory.oAndyVideosObjBLL.GetAndyVideos(VideoID, "")
                    If oclsAndyVideosObj IsNot Nothing Then
                        With oclsAndyVideosObj
                            txtTitle_tc.Text = .Title_tc
                            txtTitle_sc.Text = .Title_sc
                            txtTitle_en.Text = .Title_en
                            txtTitle_jp.Text = .Title_jp
                            tpStartDate.SelectedDate = .StartDate
                            tpExpireDate.SelectedDate = .ExpireDate
                            tpPublishDate.SelectedDate = .PublishDate
                            ddlVideoType.SelectedValue = .VideoType
                            txtVideo.Text = .Video
                            txtRemark.Text = .Remark

                            HfUrl.Value = .Photo
                            SetSmallImageUrl(imgPhoto, Server, .Photo, AndyVideoPath, NoPicture, 66, 66)

                        End With
                    End If
                Else
                    Page.ClientScript.RegisterStartupScript(Me.GetType, "Message", "alert(‘參數錯誤!‘); CancelEdit();", True)
                End If
            End If
        End If
    End Sub

    Private Sub btnSure_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSure.Click
        Dim strEditType As String = ""

        Dim oclsAndyVideosObj As clsAndyVideosObj
        Dim intResult As Integer

        If EditMode = "New" AndAlso tpStartDate.SelectedDate < Today Then
            Page.ClientScript.RegisterStartupScript(Me.GetType, "Message", "alert(‘生效日期不能小於今天!‘);", True)
            Exit Sub
        End If

        If tpExpireDate.SelectedDate < tpStartDate.SelectedDate Then
            Page.ClientScript.RegisterStartupScript(Me.GetType, "Message", "alert(‘截止日期不能小於生效日期!‘);", True)
            Exit Sub
        End If

        If tpPublishDate.SelectedDate < tpStartDate.SelectedDate Then
            Page.ClientScript.RegisterStartupScript(Me.GetType, "Message", "alert(‘發佈日期不能小於生效日期!‘);", True)
            Exit Sub
        End If

        If tpExpireDate.SelectedDate < tpPublishDate.SelectedDate Then
            Page.ClientScript.RegisterStartupScript(Me.GetType, "Message", "alert(‘發佈日期不能大於截止日期!‘);", True)
            Exit Sub
        End If

        Try
            Dim filename As String = ""
            Dim file As UploadedFile
            Dim oDirPath As String = ""
            Dim oSmallDirPath As String = ""
            Dim img As Drawing.Image = Nothing

            If Me.RadUpload1.UploadedFiles.Count <> 0 Then
                oDirPath = Server.MapPath(AndyVideoPath)
                If IO.Directory.Exists(oDirPath) = False Then
                    IO.Directory.CreateDirectory(oDirPath)
                End If

                oSmallDirPath = Server.MapPath(SmallAndyVideoPath)
                If IO.Directory.Exists(oSmallDirPath) = False Then
                    IO.Directory.CreateDirectory(oSmallDirPath)
                End If

                file = RadUpload1.UploadedFiles.Item(0)
                If Not [Object].Equals(file, Nothing) Then
                    Dim oImage As Drawing.Image = Drawing.Image.FromStream(file.InputStream)
                    If oImage IsNot Nothing Then
                        If oImage.Width > 2000 OrElse oImage.Height > 2000 Then
                            Page.ClientScript.RegisterStartupScript(Me.GetType, "Message", "alert(‘您的圖片太大,圖片寬高不能超過2000px‘);", True)
                            Exit Sub
                        End If
                    End If

                    filename = Now.ToString("yyyyMMddHHmmssfff") + file.GetExtension
                    file.SaveAs(oDirPath + filename, True)

                    img = CType(Drawing.Image.FromStream(file.InputStream), Drawing.Image)
                    imageProc.MakeThumbnailPhoto(img, oSmallDirPath + filename, 308, 154)

                    HfUrl.Value = filename
                End If
            End If

            If EditMode = "New" Then
                VideoID = clsBllFactory.oAndyVideosObjBLL.GetObjectID()
                oclsAndyVideosObj = New clsAndyVideosObj(VideoID)
                oclsAndyVideosObj.IsPublish = False
                oclsAndyVideosObj.IsNew = True
            Else
                oclsAndyVideosObj = clsBllFactory.oAndyVideosObjBLL.GetAndyVideos(VideoID, "")
                If oclsAndyVideosObj Is Nothing Then
                    Page.ClientScript.RegisterStartupScript(Me.GetType, "Message", "alert(‘该商品目錄不存在或已被删除 !‘); CancelEdit();", True)
                    Exit Sub
                End If
                oclsAndyVideosObj.Dirty = True
            End If

            With oclsAndyVideosObj
                .Title_tc = txtTitle_tc.Text
                .Title_sc = txtTitle_sc.Text
                .Title_en = txtTitle_en.Text
                .Title_jp = txtTitle_jp.Text
                .StartDate = tpStartDate.SelectedDate
                .ExpireDate = tpExpireDate.SelectedDate
                .PublishDate = tpPublishDate.SelectedDate
                .VideoType = ddlVideoType.SelectedValue
                .Video = txtVideo.Text
                .Remark = txtRemark.Text
                .Photo = HfUrl.Value
            End With

            If EditMode = "New" Then
                intResult = clsBllFactory.oAndyVideosObjBLL.InsertAndyVideos(oclsAndyVideosObj, Nothing)
                strEditType = "1"
            Else
                intResult = clsBllFactory.oAndyVideosObjBLL.UpdateAndyVideos(oclsAndyVideosObj, Nothing)
                strEditType = "2"
            End If

            If intResult = 1 Then
                Page.ClientScript.RegisterStartupScript(Me.GetType, "Message", "CloseAndRebind(‘succeed‘,‘" + strEditType + "‘);", True)
            Else
                Page.ClientScript.RegisterStartupScript(Me.GetType, "Message", "CloseAndRebind(‘fail‘,‘" + strEditType + "‘);", True)
            End If
        Catch ex As Exception

        End Try
    End Sub

End Class

  

  

  

时间: 2024-11-10 15:16:53

Telerik RadGrid Demo的相关文章

telerik:RadGrid 分组自动展开

在 MasterTableView 加上 GroupsDefaultExpanded = " true " 即可 自动展开分组下面的子项 原文地址:https://www.cnblogs.com/wrq6/p/10123338.html

Telerik for AJAX RadGrid控件

作为一名.net小白,今天分享一下telerik知识的学习.熟悉ASP.NET Web Form的都知道Grid View或者是List View等表格控件,所以今天和大家分享一下telerik RadGrid的简单应用. 和一般表格控件一样,RadGrid有Datasource和一些点击事件,一些属性(例如分页,编辑,删除) <telerik:RadGrid ID="RadGrid" runat="server" AllowPaging="true

RadGrid使用技巧:从RadGrid获取绑定的值

本文主要介绍从RadGrid获取绑定的值,仅适用于Telerik RadControls for asp.net ajax. 获取方式 RadGrid把绑定的值存储在VIewState中,即使ViewState被禁用依然会生成相应的ViewState值:它主要提供了两种方式来获取绑定的值: 1.从绑定的DataKeyValues获取 使用此功能必须先给RadGrid的MasterTableView设置DataKeyNames,可以设置多个字段(中间用逗号隔开): <MasterTableView

UWP中使用Telerik UI For UWP

国际惯例先上一张图吧: 首先去下载Telerik UI For UWP的SDK,安装好之后在项目中添加SDK的引用 建议使用引用SDK,如果引用dll的话需要引用的dll较多不太方便 引用好之后以一个柱状图为例来看看怎么使用: 在Xaml中引入两个命名空间: 使用SDK中的UnboundMode控件: 数据我写死了容易观察Demo,实际使用中建议使用数据绑定来操作,SDK包里有许多控件和表格,每个Sample都有Demo以供查看...照着改就行了~ 总之UWP的第三方控件库比较少,能拿出来用的更

WPF第三方控件Telerik

帮助文档:http://www.telerik.com/help/wpf/gridview-selection-via-checkbox.html Telerik专注于微软.Net平台的表示层与内容管理控件. Telerik Controls 2010 Q2控件组包括如下组件: Telerik RadControls for ASP.NET AJAX RadControls for ASP.NET是一套强大的用户界面控件套装,它可以帮助您创建拥有桌面应用程序华丽外表和高速性能的Web应用程序.1

Telerik 控件本地化

一共四种方式: Localization using built-in resources Resource keys Localization using ResourceManager Localization using custom localization manager 1.使用自带的语言包 具体做法: 在app.xaml.cs 里面添加: Thread.CurrentThread.CurrentCulture = new CultureInfo("de"); Thread

Telerik Kendo UI 那点事【2】

CSDN上有一个引路蜂软件的博客,里面有kendo ui的一般用法.它那里讲过的我这里就不再继续重复. 由于框架设计的需要,后台使用spring,前台使用kendo ui构建页面.为了加快快发速度以及底层兼容性,义不容辞的,继续选择了hibernate作为数据库沟通的桥梁.spring方面的例子全网就更多了,主要采用spring注解方式的MVC配置,使用json数据映射器. 经过初步的使用,发现kendo ui的设计极为强大,其MVVM的特性与spring的MVC特性结合,配合hibernate

微信h5支付demo微信H5支付demo非微信浏览器支付demo微信wap支付

一.首先先确定H5支付权限已经申请!(需要微信h5支付demo的可以加 851 488 243 备注:h5支付) 二.开发流程 1.用户在商户侧完成下单,使用微信支付进行支付 2.由商户后台向微信支付发起下单请求(调用统一下单接口)注:交易类型trade_type=MWEB 3.统一下单接口返回支付相关参数给商户后台,如支付跳转url(参数名"mweb_url"),商户通过mweb_url调起微信支付中间页 4.中间页进行H5权限的校验,安全性检查(此处常见错误请见下文) 5.如支付成

Maven+SpringMVC+Freemarker入门Demo

1 参考http://blog.csdn.net/haishu_zheng/article/details/51490299,用第二种方法创建一个名为mavenspringmvcfreemarker的Maven工程. 2 文件目录结构如下图所示 3 在pom.xml中添加springmvc和freemarker的依赖包,添加完之后的完整内容为 [html] view plain copy <project xmlns="http://maven.apache.org/POM/4.0.0&q