Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
50 views
I have a ASP.NET website that allows the user to stay logged in for an indefinite time.  I am trying to show a certain page or non closable rad window etc. every 30 days.  Right now I put the code below in my Master Page. The problem is that this runs on every page and I am sure there is a better way to do this.  I would redirect them to a page that checked this on login but they do not login for each visit.  I thought there may be a way to use the Global.asax page.  Any thought would be greatly appreciated.
if( !IsPostBack)
        {
            // Show Must Read Message When Profile Message Column is set to "Show"
                if (Profile.Message == "Show")
                {
                    Response.Redirect("~/xProfileMessage.aspx");
                }
 
            // Show Update Profile Page Every 30 days
                int DaysSinceProfileUpdate = (DateTime.Now - Profile.LastUpdatedDate).Days;
                 
                if (DaysSinceProfileUpdate > 30)
                {
                    Response.Redirect("~/xEditProfileAuto.aspx");
                }
}
Marin Bratanov
Telerik team
 answered on 07 Apr 2011
2 answers
65 views
I was playing with the dashboard recently and trying to adapt it to an alternate datasource but after trying to track down a problem I was encountering I noticed that it's actually a problem in the Sales Dashboard example itself. When you click on a person's name the silverlight controls in the main content area all update based off of an employee id being access in the Javascript, but the silverlight controls don't update correctly on the first attempt.

Sales Dashboard Example

If you open up the example, you'll get metrics for the first peron in the list, Nancy. And the Representative Sales of that first pair of data points is $7,332 (first green bar). If you select the next person over (Andrew), you'll notice the Rep Sales total of that first green bar stays at $7,332, it doesn't update at all. But if you select Andrew again, it NOW updates and shows the correct value of $3,099. After playing with the code that drives this I came to the conclusion that although the content for the main panel is being updated via using AJAX, the page is not correctly updating the Id that is stored in Javascript for access by the silverlight controls.

My question is, given this problem (if I'm right) how would you fix it? I mean, aren't the examples supposed to show working demos ;-)
Iana Tsolova
Telerik team
 answered on 07 Apr 2011
1 answer
231 views
I have a RadGrid with 2 inner layers of details tables.

I set this.radGrid.MasterTableView.HierarchyDefaultExpanded = true; before rebinding my grid for the export but it only expands 1 inner details table. How to expand all inner details tables? Thanks,
Pooya
Top achievements
Rank 1
 answered on 07 Apr 2011
5 answers
277 views
I am trying to accomplish using a single Radgrid for 7 different tables.  (one aspx page)  I am also wrapping my datasource updates (CRUD) in a Property procedure.  It is working pretty well except for inserting a new row in a table.  My problem is that it is posting the update to the radgrid control and the database twice,  I have spent many hours trying to debug my problem using the call stack and various other methods and what I have determined is that when I press the Insert link button (in-place editing), it is running the Radgrid_InsertCommand procedure twice and I am going slowly mad trying to figure out why.  My code is attached,  This could be a real challenge for the telerik MVPs. (or not!)  Thanks in advance.  (if I could, I would award 1000 points - but that's another site ;->)
P.S.  The Delete and Update commands work just fine using this code.  The difference is the insert process is activated from a RadButton outside the grid.  My aspx file has only the OnInsert, OnDelete, OnUpdate Commands.and the various SQLDataSources  The grid columns are built dynamically in code behind depending on the table the user chooses.
Protected Sub rgDisplay_InsertCommand(sender As Object, e As Telerik.Web.UI.GridCommandEventArgs) Handles rgDisplay.InsertCommand
        Dim editeditem As GridEditableItem = CType(e.Item, GridEditableItem)
        Dim dataTbl As DataTable = Me.GridSource
        Dim newRow As DataRow = dataTbl.NewRow
  
            Try 'calculate the next record key
                cmd.CommandText = "SELECT MAX(CMT_REC_ID) FROM tblTSComments"
                cmd.Connection = conn
                conn.Open()
                intLastKey = Convert.ToInt16(cmd.ExecuteScalar().ToString)
                intLastKey += 1
            Finally
                conn.Close()
            End Try
  
            Dim newValues As Hashtable = New Hashtable
            e.Item.OwnerTableView.ExtractValuesFromItem(newValues, editeditem)
            Try
                For Each entry As DictionaryEntry In newValues
                    If entry.Key = "CMT_REC_ID" Then
                        newRow("CMT_REC_ID") = intLastKey
                    Else
                        newRow(entry.Key) = entry.Value
                    End If
                Next
                dataTbl.Rows.Add(newRow)
                Me.GridSource = dataTbl
            Catch ex As Exception
                ' Error message goes here
                e.Canceled = True
            End Try
    End Sub
Private Property GridSource As DataTable
        Get
            Dim obj As Object = Me.ViewState("_gvs")
            If (Not obj Is Nothing) Then
                Return CType(obj, DataTable)
            Else
                Dim intRpt As Integer = Request("Report")
                Select Case intRpt
                    Case 0 'Comments
                        adp.SelectCommand = New OleDbCommand("SELECT CMT_REC_ID, CMT_DESCRIPTION FROM tblTSComments", conn)
                        Dim cmtstbl As New DataTable
                        conn.Open()
                        Try
                            adp.Fill(cmtstbl)
                        Finally
                            conn.Close()
                        End Try
                        Me.ViewState("_gvs") = cmtstbl
                        Return cmtstbl
                    Case 1 'Teams
                        adp.SelectCommand = New OleDbCommand("SELECT CT_TEAM_REC_ID, CT_TEAM_NAME, CT_REPORTS_TO FROM tblControllerTeam", conn)
                        Dim teamTbl As New DataTable
                        conn.Open()
                        Try
                            adp.Fill(teamTbl)
                        Finally
                            conn.Close()
                        End Try
                        Me.ViewState("_gvs") = teamTbl
                        Return teamTbl
                    Case 2 'Status
                        adp.SelectCommand = New OleDbCommand("SELECT TCS_STATUS_CODE, TCS_DESCRIPTION FROM tblEmplStatus", conn)
                        Dim statusTbl As New DataTable
                        conn.Open()
                        Try
                            adp.Fill(statusTbl)
                        Finally
                            conn.Close()
                        End Try
                        Me.ViewState("_gvs") = statusTbl
                        Return statusTbl
                    Case 3 'PayPeriod
                        adp.SelectCommand = New OleDbCommand("SELECT PAYPERIOD, PAYPERIODNBR, PAYPERIODLOCKED, PAYPERIODLOCKEDDATE, PAYPERIODLOCKID FROM PayPeriods ORDER BY PAYPERIOD", conn)
                        Dim ppTbl As New DataTable
                        conn.Open()
                        Try
                            adp.Fill(ppTbl)
                        Finally
                            conn.Close()
                        End Try
                        Me.ViewState("_gvs") = ppTbl
                        Return ppTbl
                    Case 4 'Team Leader
                        adp.SelectCommand = New OleDbCommand("SELECT OPF_NTUSER_ID, OPF_FNAME, OPF_MINIT, OPF_LNAME, OPF_REGION FROM tblOpsFacilitator", conn)
                        Dim leadTbl As New DataTable
                        conn.Open()
                        Try
                            adp.Fill(leadTbl)
                        Finally
                            conn.Close()
                        End Try
                        Me.ViewState("_gvs") = leadTbl
                        Return leadTbl
                    Case 5 'Vacation and Pers Choice Available
                        adp.SelectCommand = New OleDbCommand("SELECT TTE_NTUSER_ID, TTE_SOCIAL_SECURITY_NBR, TTE_FNAME + ' ' + TTE_LNAME AS NAME, TTE_TOTL_VAC_AVAIL, TTE_TOTL_PERS_CHOICE_AVAIL FROM tblTCCTimeCardEmployees WHERE TTE_EMPL_STATUS = 'A' ORDER BY TTE_NTUSER_ID", conn)
                        Dim vacPCHTbl As New DataTable
                        conn.Open()
                        Try
                            adp.Fill(vacPCHTbl)
                        Finally
                            conn.Close()
                        End Try
                        Me.ViewState("_gvs") = vacPCHTbl
                        Return vacPCHTbl
                    Case 6 'Rates
                        adp.SelectCommand = New OleDbCommand("SELECT TTE_NTUSER_ID, TTE_SOCIAL_SECURITY_NBR, TTE_FNAME + ' ' + TTE_LNAME AS NAME, TTE_EMPL_CATEGORY, TTE_CALC_TIMESHEET, TTE_FIVE_PCNT_RATE, TTE_TEN_PCNT_RATE FROM tblTCCTimeCardEmployees WHERE TTE_EMPL_STATUS = 'A' ORDER BY TTE_NTUSER_ID", conn)
                        Dim rateTbl As New DataTable
                        conn.Open()
                        Try
                            adp.Fill(rateTbl)
                        Finally
                            conn.Close()
                        End Try
                        Me.ViewState("_gvs") = rateTbl
                        Return rateTbl
                End Select
            End If
        End Get
        Set(value As DataTable)
            Dim intRpt As Integer = Request("Report")
            Select Case intRpt
                Case 0 'Comments
                    Try
                        adp.SelectCommand = New OleDbCommand("SELECT CMT_REC_ID, CMT_DESCRIPTION FROM tblTSComments", conn)
                        Dim cmdBldr As OleDbCommandBuilder = New OleDbCommandBuilder(adp)
                        conn.Open()
                        adp.Update(value)
                    Catch ex As Exception
                        'Error during update, add code to locate error, reconcile and try again
                    Finally
                        conn.Close()
                    End Try
                Case 1 'Teams
                    Try
                        adp.SelectCommand = New OleDbCommand("SELECT CT_TEAM_REC_ID, CT_TEAM_NAME, CT_REPORTS_TO FROM tblControllerTeam", conn)
                        Dim cmdBldr As OleDbCommandBuilder = New OleDbCommandBuilder(adp)
                        conn.Open()
                        adp.Update(value)
                    Catch ex As Exception
                        'Error during update, add code to locate error, reconcile and try again
                    Finally
                        conn.Close()
                    End Try
                Case 2 'Status
                    Try
                        adp.SelectCommand = New OleDbCommand("SELECT TCS_STATUS_CODE, TCS_DESCRIPTION FROM tblEmplStatus", conn)
                        Dim cmdBldr As OleDbCommandBuilder = New OleDbCommandBuilder(adp)
                        conn.Open()
                        adp.Update(value)
                    Catch ex As Exception
                        'Error during update, add code to locate error, reconcile and try again
                    Finally
                        conn.Close()
                    End Try
                Case 3 'PayPeriod
                    Try
                        adp.SelectCommand = New OleDbCommand("SELECT PAYPERIOD, PAYPERIODNBR, PAYPERIODLOCKED, PAYPERIODLOCKEDDATE, PAYPERIODLOCKID FROM PayPeriods ORDER BY PAYPERIOD", conn)
                        Dim cmdBldr As OleDbCommandBuilder = New OleDbCommandBuilder(adp)
                        conn.Open()
                        adp.Update(value)
                    Catch ex As Exception
                        'Error during update, add code to locate error, reconcile and try again
                    Finally
                        conn.Close()
                    End Try
                Case 4 'Team Leader
                    Try
                        adp.SelectCommand = New OleDbCommand("SELECT OPF_NTUSER_ID, OPF_FNAME, OPF_MINIT, OPF_LNAME, OPF_REGION FROM tblOpsFacilitator", conn)
                        Dim cmdBldr As OleDbCommandBuilder = New OleDbCommandBuilder(adp)
                        conn.Open()
                        adp.Update(value)
                    Catch ex As Exception
                        'Error during update, add code to locate error, reconcile and try again
                    Finally
                        conn.Close()
                    End Try
                Case 5 'Vacation and Pers Choice Available
                    Try
                        adp.SelectCommand = New OleDbCommand("SELECT TTE_NTUSER_ID, TTE_SOCIAL_SECURITY_NBR, TTE_FNAME + ' ' + TTE_LNAME AS NAME, TTE_TOTL_VAC_AVAIL, TTE_TOTL_PERS_CHOICE_AVAIL FROM tblTCCTimeCardEmployees WHERE TTE_EMPL_STATUS = 'A' ORDER BY TTE_NTUSER_ID", conn)
                        Dim cmdBldr As OleDbCommandBuilder = New OleDbCommandBuilder(adp)
                        conn.Open()
                        adp.Update(value)
                    Catch ex As Exception
                        'Error during update, add code to locate error, reconcile and try again
                    Finally
                        conn.Close()
                    End Try
                Case 6 'Rates
                    Try
                        adp.SelectCommand = New OleDbCommand("SELECT TTE_NTUSER_ID, TTE_SOCIAL_SECURITY_NBR, TTE_FNAME + ' ' + TTE_LNAME AS NAME, TTE_EMPL_CATEGORY, TTE_CALC_TIMESHEET, TTE_FIVE_PCNT_RATE, TTE_TEN_PCNT_RATE FROM tblTCCTimeCardEmployees WHERE TTE_EMPL_STATUS = 'A' ORDER BY TTE_NTUSER_ID", conn)
                        Dim cmdBldr As OleDbCommandBuilder = New OleDbCommandBuilder(adp)
                        conn.Open()
                        adp.Update(value)
                    Catch ex As Exception
                        'Error during update, add code to locate error, reconcile and try again
                    Finally
                        conn.Close()
                    End Try
            End Select
        End Set
    End Property
  
    Protected Sub cmdAdd_Click(sender As Object, e As System.EventArgs) Handles cmdAdd.Click
        rgDisplay.MasterTableView.InsertItem()
    End Sub
End Class
Chuck Harrington
Top achievements
Rank 1
 answered on 07 Apr 2011
5 answers
171 views
Hi,
I am using Vertical RadSpliter  with 2 RadPane inside. But as I collapse the left pane, the collapse/resize button disappears and I cannot rezise this right pane. The left pane is also partially hidden by the vertical scroll bar.

I really need you help to solve the problem. This is very urgent.

Thanks,
Hai Tran
Hai
Top achievements
Rank 1
 answered on 07 Apr 2011
2 answers
67 views
Hi there,

I'm trying to develop an aspx website to dynamically generate HTML pages made up of predefined elements stored in a database.

Basically the generated pages consist of elements occupying 50% of the width of the page, and elements spanning 100%.
I'd like to create a drag and drop interface allowing users to drag the predefined elements to a 'layout' grid containing two columns. One for the left part of the generated html file, and one for the right part. The dropped elements should then be edited by the user so that he/she can input values like name and id for each dropped element.

Any suggestions which controlls to use and how to use them?
Thanks in advance.

Erik
Erik
Top achievements
Rank 1
 answered on 07 Apr 2011
1 answer
73 views

Hi,

I have a telrik grid which shows Hierarchical data in telrik grid. I want to populate one more grid(gridTeamMembers) in code below when user selects a row from detailtables ie groupID. I have problem selecting the groupID of Hierarchical  grid which I want to pass to the 3rd grid(gridTeamMembers). I want to use this groupID in SqlDataSource3 to populate the gridTeamMembers grid.

Please help. Here is my code.

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
   <script type="text/javascript">
     //<![CDATA[
    

       var grid;

       function GridCreated() {
           grid = this;
       }

     
     
          //]]>
        </script>
       
   
</head>
<body>
    <form runat="server" id="mainForm" method="post">
      
     <telerik:RadScriptManager ID="RadScriptManager1" runat="server" />
        <!-- content start -->
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="RadGrid1">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="RadGrid1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>

        <telerik:RadSplitter ID="RadSplitter1" Width="700px" runat="server" Orientation="Vertical">
            <telerik:RadPane ID="gridPane" runat="server" Height="307px"
                Scrolling="None">
               

        <telerik:RadGrid ID="RadGrid1" OnPreRender="RadGrid1_PreRender" ShowStatusBar="true" DataSourceID="SqlDataSource1"
            runat="server" AutoGenerateColumns="False" PageSize="7" AllowSorting="True" AllowMultiRowSelection="true"
            AllowPaging="True" GridLines="None">
            <PagerStyle Mode="NumericPages"></PagerStyle>
          
            <MasterTableView DataSourceID="SqlDataSource1" DataKeyNames="MainGroupID" AllowMultiColumnSorting="True">
          
                <DetailTables>
                    <telerik:GridTableView DataKeyNames="GroupID" DataSourceID="SqlDataSource2" Width="100%"
                        runat="server">
                      
                        <ParentTableRelation>
                            <telerik:GridRelationFields DetailKeyField="MainGroupID" MasterKeyField="MainGroupID" />
                        </ParentTableRelation>
                       
                        <Columns>
                            <telerik:GridTemplateColumn UniqueName="GroupID" DataField="GroupID">
                                <ItemTemplate>
                                    <asp:Label ID="Label1" Font-Bold="true" Font-Italic="true" Text='<%# Eval("GroupID") %>' Visible="false" runat="server" />
                                </ItemTemplate>
                            </telerik:GridTemplateColumn>
                            <telerik:GridBoundColumn SortExpression="GroupID" HeaderText="GroupID" HeaderButtonType="TextButton"
                                DataField="GroupID" UniqueName="GroupID">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn SortExpression="GroupName" HeaderText="Group Name" HeaderButtonType="TextButton"
                                DataField="GroupName" UniqueName="GroupName">
                            </telerik:GridBoundColumn>                           
                        </Columns>
                        <SortExpressions>
                            <telerik:GridSortExpression FieldName="GroupName"></telerik:GridSortExpression>
                        </SortExpressions>
                      
                    </telerik:GridTableView>
                </DetailTables>
                <Columns>
                   
                    <telerik:GridBoundColumn SortExpression="MainGroupID" HeaderText="MainGroupID" HeaderButtonType="TextButton"
                        DataField="MainGroupID" UniqueName="MainGroupID">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn SortExpression="MainGroupName" HeaderText="MainGroup Name" HeaderButtonType="TextButton"
                        DataField="MainGroupName" UniqueName="MainGroupName">
                    </telerik:GridBoundColumn>
                   
                </Columns>
                <SortExpressions>
                    <telerik:GridSortExpression FieldName="MainGroupName"></telerik:GridSortExpression>
                </SortExpressions>
                
            </MasterTableView>
            <ClientSettings EnablePostBackOnRowClick="true">
                            <Selecting AllowRowSelect="True" />
                        </ClientSettings>
        </telerik:RadGrid>

         </telerik:RadPane>
            <telerik:RadSplitBar CollapseMode="Both" ID="RadSplitBar2" runat="server" EnableResize="True">
            </telerik:RadSplitBar>
            <telerik:RadPane ID="listBoxPane" runat="server" CssClass="TextStyle" BackColor="#d9eeff">
               
                   <div id="divTeamMembers" style="height:260px;overflow-y:auto;padding:10px 10px 10px 10px; margin:10px 10px 10px 10px;">
                          <telerik:RadGrid ID="gridTeamMembers" runat="server"
                            DataSourceID="SqlDataSource3" Skin="Office2007"                            
                            AllowSorting="true" AllowPaging="false" AllowFilteringByColumn="false"
                            AutoGenerateColumns="false" ShowStatusBar="true" AllowMultiRowSelection="True"
                            Width="99%"
                            >
                                                   
                          
                           <MasterTableView Width="100%" DataKeyNames="MemID"
                                CommandItemDisplay="Top"    DataSourceID="dsTeamMemberInfo"
                                HorizontalAlign="NotSet"
                                AutoGenerateColumns="False"
                                AllowAutomaticUpdates="False"
                                AllowAutomaticInserts="False"
                                AllowAutomaticDeletes="False"
                                EditMode="PopUp">

                           

                            <Columns>
                              
                                <telerik:GridBoundColumn UniqueName="FirstName" DataField="FirstName" HeaderText="First Name" SortExpression="FirstName" AllowFiltering="false" ItemStyle-HorizontalAlign="Left" />
                                <telerik:GridBoundColumn UniqueName="LastName" DataField="LastName" HeaderText="Last Name" SortExpression="LastName" AllowFiltering="false" ItemStyle-HorizontalAlign="Left" />
                              
                            </Columns>
                        </MasterTableView>
                        <ClientSettings EnableRowHoverStyle="true">
                            <Selecting AllowRowSelect="True" />
                             <ClientEvents OnGridCreated="GridCreated"></ClientEvents>                                                         
                        </ClientSettings>                                                           
                        </telerik:RadGrid>
                        </div>
                
            </telerik:RadPane>
        </telerik:RadSplitter>

        <asp:SqlDataSource ID="SqlDataSource1" ConnectionString="<%$ ConnectionStrings:testConnectionString %>"
            ProviderName="System.Data.SqlClient" SelectCommand="SELECT * FROM TestGroups"
            runat="server"></asp:SqlDataSource>
        <asp:SqlDataSource ID="SqlDataSource2" ConnectionString="<%$ ConnectionStrings:testConnectionString %>"
            ProviderName="System.Data.SqlClient" SelectCommand="SELECT * FROM TestGroups1 Where MainGroupID = @MainGroupID"
            runat="server">
            <SelectParameters>
                <asp:Parameter Name="MainGroupID" Type="string" />
            </SelectParameters>
        </asp:SqlDataSource>
       
        <!-- content end -->

        <asp:SqlDataSource ID="SqlDataSource3" runat="server" 
        ConnectionString="<%$ ConnectionStrings:EIProfileConnectionString %>"
        SelectCommand="GetMemberDetail" SelectCommandType="StoredProcedure">
         <SelectParameters>
            <asp:ControlParameter ControlId="Radgrid1" Name="GroupID" PropertyName="SelectedValue" Type="Int32"/>
        </SelectParameters>
    </asp:SqlDataSource>
     
    </form>

</body>
</html>

Iana Tsolova
Telerik team
 answered on 07 Apr 2011
2 answers
549 views
Hello,

I do have a "asp image button" as a first column of radgrid and "caseNumber" viz CS123 as a second column and having hundreds of such rows.

I want to redirect to another page on clicking the image button in radgrid. like page1.aspx?ID=CS123

Can you please suggest me how I can achieve this ?

Thanks,
Prayag
prayag ganoje
Top achievements
Rank 1
 answered on 07 Apr 2011
2 answers
126 views
Hello Friends,

I have trouble on my project, and at moment I didn't get to solve it !! I have a grid and when I delete row for first time it is ok, the problem is if I delete the other line in sequence. For some reason, I can not delete any row where the ID is larger than the ID of the deleted first.

I am using telerik ajax Q3 2010 and my project is in C# Framework 4.0 !!

Could you help me with this case ??

See attached my code:

<div id="divListagem">
        <telerik:RadAjaxPanel ID="apListagem" runat="server" LoadingPanelID="lpListagem"
            Width="100%" HorizontalAlign="NotSet"
            meta:resourcekey="apListagemResource1">
            <telerik:RadGrid ID="dgListagem" runat="server" AllowFilteringByColumn="True" AllowPaging="True"
                AllowSorting="True" GridLines="None" Skin="Windows7" EnableLinqExpressions="False"
                OnItemCommand="dgListagem_ItemCommand" OnItemDataBound="dgListagem_ItemDataBound"
                OnNeedDataSource="dgListagem_NeedDataSource" CellPadding="0" Height="100%" HorizontalAlign="Center"
                PageSize="20" meta:resourcekey="dgListagemResource" >
                <SortingSettings SortedAscToolTip="Ordem Crescente" SortedDescToolTip="Ordem Decrescente"
                    SortToolTip="Clique aqui para ordenar" />
                <GroupingSettings CaseSensitive="false" />
                <ClientSettings>
                    <Scrolling UseStaticHeaders="True" />
                </ClientSettings>
                <MasterTableView AutoGenerateColumns="False" CommandItemDisplay="Top" DataKeyNames="ID" ClientDataKeyNames="ID"
                    CellPadding="0" CellSpacing="0">
                    <Columns>
                        <telerik:GridTemplateColumn AutoPostBackOnFilter="True" DataField="ID" FilterControlWidth="60px"
                            GroupByExpression="ID Group By ID" HeaderText="Código" meta:resourcekey="gtCodigoResource"
                            ShowFilterIcon="false" SortExpression="ID" UniqueName="ID">
                            <ItemTemplate>
                                <asp:Literal ID="ltrId" runat="server"></asp:Literal>
                            </ItemTemplate>
                            <HeaderStyle HorizontalAlign="Center" Width="80px" />
                            <ItemStyle HorizontalAlign="Center" Width="80px" />
                        </telerik:GridTemplateColumn>
                        <telerik:GridTemplateColumn FilterControlWidth="180px" AutoPostBackOnFilter="True" DataField="Titulo" GroupByExpression="Titulo Group By Titulo"
                            HeaderText="Titulo" meta:resourcekey="gtTituloResource" ShowFilterIcon="False" SortExpression="Titulo"
                            UniqueName="Titulo">
                            <ItemTemplate>
                                <asp:Literal ID="ltrTitulo" runat="server"></asp:Literal>
                            </ItemTemplate>
                        </telerik:GridTemplateColumn>
                        <telerik:GridTemplateColumn AutoPostBackOnFilter="True" DataField="Idioma" FilterControlWidth="180px"
                            GroupByExpression="Idioma Group By Idioma" HeaderText="Idioma" meta:resourcekey="gtIdiomaResource"
                            ShowFilterIcon="False" SortExpression="Idioma" UniqueName="Idioma">
                            <ItemTemplate>
                                <asp:Literal ID="ltrIdioma" runat="server"></asp:Literal>
                            </ItemTemplate>
                            <HeaderStyle HorizontalAlign="Center" Width="200px" />
                            <ItemStyle HorizontalAlign="Center" Width="200px" />
                        </telerik:GridTemplateColumn>
                        <telerik:GridTemplateColumn AllowFiltering="False" UniqueName="TemplateColumn">
                            <ItemTemplate>
                                <asp:HyperLink ID="hplEdit" runat="server" meta:resourcekey="hplEditResource" ImageUrl="/CMS/Estrutura/Image/lista_edit.png"></asp:HyperLink>
                            </ItemTemplate>
                            <HeaderStyle HorizontalAlign="Center" Width="19px" />
                            <ItemStyle HorizontalAlign="Center" Width="19px" />
                        </telerik:GridTemplateColumn>
                        <telerik:GridTemplateColumn AllowFiltering="False" UniqueName="TemplateColumn1">
                            <ItemTemplate>
                                <asp:ImageButton ID="ibtExcluir" runat="server" CommandName="Excluir" ImageUrl="/CMS/Estrutura/image/lista_delete.png"
                                    meta:resourcekey="ibtExcluirResource" />
                            </ItemTemplate>
                            <HeaderStyle HorizontalAlign="Center" Width="20px" />
                            <ItemStyle HorizontalAlign="Center" Width="20px" />
                        </telerik:GridTemplateColumn>
                    </Columns>
                    <CommandItemTemplate>
                        <div class="CabecalhoBotaoGrid">
                            <table width="100%">
                                <tr>
                                    <td align="center">
                                          
                                    </td>
                                </tr>
                            </table>
                        </div>
                    </CommandItemTemplate>
                </MasterTableView>
                <HeaderContextMenu EnableImageSprites="True" CssClass="GridContextMenu GridContextMenu_Default">
                </HeaderContextMenu>
            </telerik:RadGrid>
        </telerik:RadAjaxPanel>
        <telerik:RadAjaxLoadingPanel ID="lpListagem" runat="server" Skin="Windows7" meta:resourcekey="lpListagemResource1">
            <div id="loading">
                <asp:Literal ID="ltrLoading" runat="server"
                    meta:resourcekey="ltrLoadingResource1"></asp:Literal>
            </div>
        </telerik:RadAjaxLoadingPanel>
    </div>


protected void dgListagem_ItemCommand(object sender, GridCommandEventArgs e)
        {
            try
            {
                if (e.CommandName == "Excluir")
                {
                    GridEditableItem editeditem = (GridEditableItem)e.Item;
                    int codigo = Convert.ToInt32(editeditem.OwnerTableView.DataKeyValues[editeditem.ItemIndex]["ID"].ToString());
 
                    try
                    {
                        BLFaq.Delete(codigo);
                        dgListagem.Rebind();
                    }
                    catch
                    {
                        RadScriptManager.RegisterStartupScript(this.Page, this.GetType(), "showError", string.Format("javascript:alert('{0}')", txtErrorParent.Value), true);
                    }
                }
            }
            catch (Exception ex)
            {
                BAL.BLError.TrataErro(new Model.MLError() { Ex = ex, Page = this.Page });
            }
        }
 
        protected void dgListagem_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
        {
            try
            {
                dgListagem.DataSource = BLFaq.SelectListagem();
            }
            catch (Exception ex)
            {
                BAL.BLError.TrataErro(new Model.MLError() { Ex = ex, Page = this.Page });
            }
        }
 
        protected void dgListagem_ItemDataBound(object sender, GridItemEventArgs e)
        {
            var obj = e.Item.DataItem as MLFaq;
            if (obj == null) return;
 
            if (!(e.Item is GridDataItem)) return;
 
            GridDataItem item = (GridDataItem)e.Item;
            Literal control;
 
            //Id
            Literal ltrId = item.FindControl("ltrId") as Literal;
            ltrId.Text = obj.Id.ToString();
 
            //Titulo
            Literal ltrTitulo = item.FindControl("ltrTitulo") as Literal;
            ltrTitulo.Text = obj.Titulo;
 
            ////Texto
            //control = item.FindControl("ltrTexto") as Literal;
            //control.Text = obj.Texto;
 
            //Idioma
            Literal ltrIdioma = item.FindControl("ltrIdioma") as Literal;
            ltrIdioma.Text = obj.Idioma;
 
            //Editar
            var edit = item.FindControl("hplEdit") as HyperLink;
            var qs = new SecureQueryString();
            qs["IdItem"] = obj.Id.ToString();
            qs["indice"] = param.Index;
            qs["Update"] = Update.ToString();
            qs["Publish"] = Publish.ToString();
            qs["ItemMenuId"] = param.ItemMenuId.ToString();
            qs["MenuId"] = param.MenuId.ToString();
            qs["MenuName"] = param.MenuName;
 
            if (!Update)
            {
                edit.ImageUrl = "~/CMS/Imagens/pesquisar.png";
                edit.ToolTip = "Visualizar Cadastro";
            }
            else
            {
                edit.ToolTip = "Editar Cadastro";
            }
            edit.NavigateUrl = string.Format("Cadastro.aspx?IdItem={0}", qs);
 
            //Excluir
            var delete = item.FindControl("ibtExcluir") as ImageButton;
            if (!Delete)
            {
                delete.Enabled = false;
                delete.ImageUrl = "~/CMS/Estrutura/Image/lista_delete_off.png";
                delete.ToolTip = "Sem permissão para Excluir";
            }
            else
            {
                delete.ToolTip = "Excluir Registro" ;
                delete.OnClientClick = string.Format("javascript:return confirm('{0}');", txtMessage.Value);
            }
        }
 
    }
}

Daniel
Top achievements
Rank 1
 answered on 07 Apr 2011
Narrow your results
Selected tags
Tags
+? more
Top users last month
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?