Telerik Forums
UI for ASP.NET AJAX Forum
4 answers
309 views
Hi,
I added a radgrid with nested template in my web part for sharepoint 2010. I managed to get the radgrid to display items from sharepoint lists but I can't seem to trigger any update or insert events. I have attached my codes as follows.

<%@ Assembly Name="$SharePoint.Project.AssemblyFullName$" %>
<%@ Assembly Name="Microsoft.Web.CommandUI, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register TagPrefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register TagPrefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register TagPrefix="asp" Namespace="System.Web.UI" Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
<%@ Import Namespace="Microsoft.SharePoint" %>
<%@ Register TagPrefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Control Language="VB" AutoEventWireup="true" CodeBehind="ERM_RiskReportingUserControl.ascx.vb" Inherits="ERMWeb.ERM_RiskReportingUserControl" %>
<%@ Register Assembly="Telerik.Web.UI, Version=2011.1.614.35, Culture=neutral, PublicKeyToken=121fae78165ba3d4" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
        <telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="False" GridLines="Horizontal" AllowAutomaticDeletes="True" AllowAutomaticInserts="True" AllowAutomaticUpdates="True" CellSpacing="0">
            <MasterTableView DataKeyNames="ID" CommandItemDisplay="Top" EditMode="InPlace" EnableColumnsViewState="false">
                <Columns>
                    <telerik:GridBoundColumn DataField="ID" HeaderText="ID" UniqueName="ID" ReadOnly="true" ItemStyle-Width="20px"/>
                    <telerik:GridEditCommandColumn UniqueName="EditCommandColumn" ButtonType="ImageButton" ItemStyle-Width="50px"/>
                    <telerik:GridBoundColumn DataField="Strategy" HeaderText="Strategy" UniqueName="Strategy" ItemStyle-Width="400px" />
                    <telerik:GridBoundColumn DataField="RiskFactor" HeaderText="Risk Factor" UniqueName="RiskFactor" ItemStyle-Width="400px" />
                    <telerik:GridBoundColumn DataField="RiskOwner" HeaderText="Risk Owner" UniqueName="RiskOwner" ItemStyle-Width="300px" />
                    <telerik:GridDropDownColumn DataField="Impact" HeaderText="Impact" UniqueName="Impact" ItemStyle-Width="80px" />
                    <telerik:GridDropDownColumn DataField="Likelihood" HeaderText="Likelihood" UniqueName="Likelihood" ItemStyle-Width="80px" />
                </Columns>
                <NestedViewSettings>
                    <ParentTableRelation>
                        <telerik:GridRelationFields DetailKeyField="ID" MasterKeyField="ID" />
                    </ParentTableRelation>
                </NestedViewSettings>
                <NestedViewTemplate>
                    <table cellpadding="30px">
                        <tr>
                            <td>
                                <telerik:RadGrid ID="RadGrid2" runat="server" Skin="WebBlue" OnItemDataBound="RadGrid2_ItemDataBound" OnNeedDataSource="RadGrid2_NeedDataSource" AutoGenerateColumns="false" AllowAutomaticInserts="True" AllowAutomaticUpdates="True">
                                    <ClientSettings EnableRowHoverStyle="False">
                                        <Selecting AllowRowSelect="True" />
                                    </ClientSettings>
                                    <MasterTableView DataKeyNames="RiskItemID" CommandItemDisplay="Top" EditMode="InPlace">
                                        <Columns>
                                            <telerik:GridBoundColumn DataField="ID" HeaderText="ID" UniqueName="ID" ReadOnly="true" ItemStyle-Width="20px" />
                                            <telerik:GridEditCommandColumn UniqueName="EditCommandColumn" ButtonType="ImageButton" ItemStyle-Width="50px" />
                                            <telerik:GridBoundColumn DataField="RiskConsequence" HeaderText="Risk Consequence" UniqueName="RiskConsequence" ItemStyle-Width="250px" />
                                            <telerik:GridBoundColumn DataField="RiskCause" HeaderText="Risk Cause" UniqueName="RiskCause" ItemStyle-Width="250px" />
                                            <telerik:GridBoundColumn DataField="CurrentMitigation" HeaderText="Current Mitigation" UniqueName="CurrentMitigation" ItemStyle-Width="300px" />
                                            <telerik:GridBoundColumn DataField="ProposedMitigation" HeaderText="Proposed Mitigation" UniqueName="ProposedMitigation" ItemStyle-Width="300px" />
                                            <telerik:GridBoundColumn DataField="ImplementationPlan" HeaderText="Implementation Plan" UniqueName="ImplementationPlan" ItemStyle-Width="150px" />
                                            <telerik:GridDropDownColumn DataField="RiskItemID" HeaderText="" UniqueName="RiskItemID" Visible="false" ItemStyle-Width="0px"/>
                                        </Columns>
                                        <EditFormSettings>
                                            <EditColumn ButtonType="ImageButton" />
                                        </EditFormSettings>
                                        <EditItemStyle VerticalAlign="Top" />
                                    </MasterTableView>
                                </telerik:RadGrid>
                            </td>
                        </tr>
                    </table>
                </NestedViewTemplate>
                <EditFormSettings>
                    <EditColumn ButtonType="ImageButton" />
                </EditFormSettings>
                <EditItemStyle VerticalAlign="Top" />
            </MasterTableView>
        </telerik:RadGrid>


Imports System
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports Telerik.Web.UI
 
Partial Public Class RiskReportingUserControl
    Inherits UserControl
 
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
 
        Me.EnableViewState = True
 
        If Not Me.IsPostBack Then
            'BindToGrid()
            DisplayMessage("No text")
 
        End If
    End Sub
 
    Protected Function GetParentGridTable() As DataTable
 
        Dim oSiteCollection As SPSite = SPContext.Current.Site
        Dim oWebsiteRoot As SPWeb = oSiteCollection.OpenWeb()
        Dim myList As Microsoft.SharePoint.SPList
        myList = oWebsiteRoot.Lists("RiskItem")
 
        Dim results As SPListItemCollection = myList.Items
        Dim tbl As New DataTable()
        tbl.Columns.Add("ID", GetType(String))
        tbl.Columns.Add("Strategy", GetType(String))
        tbl.Columns.Add("RiskFactor", GetType(String))
        tbl.Columns.Add("RiskOwner", GetType(String))
        tbl.Columns.Add("Impact", GetType(String))
        tbl.Columns.Add("Likelihood", GetType(String))
 
        Dim row As DataRow
        For Each result As SPListItem In results
            row = tbl.Rows.Add()
            row("ID") = result("ID").ToString()
            row("Strategy") = result("Strategy").ToString()
            row("RiskFactor") = result("RiskFactor").ToString()
            row("RiskOwner") = result("RiskOwner").ToString()
            row("Impact") = result("Impact").ToString()
            row("Likelihood") = result("Likelihood").ToString()
        Next
 
        Return tbl
 
    End Function
 
    Protected Function GetChildGridTable() As DataTable
 
        Dim oSiteCollection As SPSite = SPContext.Current.Site
        Dim oWebsiteRoot As SPWeb = oSiteCollection.OpenWeb()
        Dim myList As Microsoft.SharePoint.SPList
        myList = oWebsiteRoot.Lists("RiskItemDetail")
 
        Dim results As SPListItemCollection = myList.Items
        Dim tbl As New DataTable()
        tbl.Columns.Add("ID", GetType(String))
        tbl.Columns.Add("RiskItemID", GetType(String))
        tbl.Columns.Add("RiskConsequence", GetType(String))
        tbl.Columns.Add("RiskCause", GetType(String))
        tbl.Columns.Add("CurrentMitigation", GetType(String))
        tbl.Columns.Add("ProposedMitigation", GetType(String))
        tbl.Columns.Add("ImplementationPlan", GetType(String))
 
        Dim row As DataRow
        For Each result As SPListItem In results
            row = tbl.Rows.Add()
            row("ID") = result("ID").ToString()
            row("RiskItemID") = result("RiskItemID").ToString().Remove(1)
            row("RiskConsequence") = result("RiskConsequence").ToString()
            row("RiskCause") = result("RiskCause").ToString()
            row("CurrentMitigation") = result("CurrentMitigation").ToString()
            row("ProposedMitigation") = result("ProposedMitigation").ToString()
            row("ImplementationPlan") = result("ImplementationPlan").ToString()
        Next
 
        Return tbl
 
    End Function
 
    Protected Sub BindToGrid()
 
        RadGrid1.DataSource = GetParentGridTable().DefaultView
        RadGrid1.DataBind()
 
    End Sub
 
    Protected Sub RadGrid1_NeedDataSource(ByVal source As Object, ByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles RadGrid1.NeedDataSource
        RadGrid1.DataSource = GetParentGridTable().DefaultView
    End Sub
 
    Protected Sub RadGrid2_NeedDataSource(ByVal source As Object, ByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs)
        Dim grid As RadGrid = DirectCast(source, RadGrid)
        Dim parentGridItem As GridDataItem = TryCast(TryCast(grid.NamingContainer, GridNestedViewItem).ParentItem, GridDataItem)
 
        grid.DataSource = GetChildGridTable().Select("RiskItemID = " & parentGridItem.GetDataKeyValue("ID").ToString())
 
    End Sub
 
    Protected Sub RadGrid1_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles RadGrid1.ItemDataBound
 
        If TypeOf e.Item Is GridEditableItem AndAlso e.Item.IsInEditMode Then
 
        End If
        If TypeOf e.Item Is GridDataItem AndAlso e.Item.IsInEditMode Then
            Dim item As GridDataItem = TryCast(e.Item, GridDataItem)
            Dim textItem1 As TextBox = DirectCast(item("Strategy").Controls(0), TextBox)
            textItem1.TextMode = TextBoxMode.MultiLine
            textItem1.Wrap = True
            textItem1.Width = 400
            textItem1.Style.Add("border", "1px solid #CCCCCC")
            textItem1.Style.Add("font", "10pt tahoma,sans-serif")
            textItem1.Rows = 10
            textItem1.Text = textItem1.Text.Replace("<br/>", Chr(10))
 
            Dim textItem2 As TextBox = DirectCast(item("RiskFactor").Controls(0), TextBox)
            textItem2.TextMode = TextBoxMode.MultiLine
            textItem2.Wrap = True
            textItem2.Width = 400
            textItem2.Style.Add("border", "1px solid #CCCCCC")
            textItem2.Style.Add("font", "10pt tahoma,sans-serif")
            textItem2.Rows = 10
            textItem2.Text = textItem2.Text.Replace("<br/>", Chr(10))
 
            Dim textItem3 As TextBox = DirectCast(item("RiskOwner").Controls(0), TextBox)
            textItem3.TextMode = TextBoxMode.MultiLine
            textItem3.Wrap = True
            textItem3.Width = 300
            textItem3.Style.Add("border", "1px solid #CCCCCC")
            textItem3.Style.Add("font", "10pt tahoma,sans-serif")
            textItem3.Rows = 3
            textItem3.Text = textItem3.Text.Replace("<br/>", Chr(10))
 
            Dim ddl1 As RadComboBox = DirectCast(item("Impact").Controls(0), RadComboBox)
            ddl1.Width = 80
            ddl1.Style.Add("border", "1px solid #CCCCCC")
            ddl1.Style.Add("font", "10pt tahoma,sans-serif")
 
            Dim ddl2 As RadComboBox = DirectCast(item("Likelihood").Controls(0), RadComboBox)
            ddl2.Width = 80
            ddl2.Style.Add("border", "1px solid #CCCCCC")
            ddl2.Style.Add("font", "10pt tahoma,sans-serif")
 
        End If
 
    End Sub
 
    Protected Sub RadGrid2_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs)
 
        If TypeOf e.Item Is GridDataItem AndAlso e.Item.IsInEditMode Then
            Dim item As GridDataItem = TryCast(e.Item, GridDataItem)
            Dim textItem1 As TextBox = DirectCast(item("RiskConsequence").Controls(0), TextBox)
            textItem1.TextMode = TextBoxMode.MultiLine
            textItem1.Wrap = True
            textItem1.Width = 250
            textItem1.Style.Add("border", "1px solid #CCCCCC")
            textItem1.Style.Add("font", "10pt tahoma,sans-serif")
            textItem1.Rows = 10
            textItem1.Text = textItem1.Text.Replace("<br/>", Chr(10))
 
            Dim textItem2 As TextBox = DirectCast(item("RiskCause").Controls(0), TextBox)
            textItem2.TextMode = TextBoxMode.MultiLine
            textItem2.Wrap = True
            textItem2.Width = 250
            textItem2.Style.Add("border", "1px solid #CCCCCC")
            textItem2.Style.Add("font", "10pt tahoma,sans-serif")
            textItem2.Rows = 10
            textItem2.Text = textItem2.Text.Replace("<br/>", Chr(10))
 
            Dim textItem3 As TextBox = DirectCast(item("CurrentMitigation").Controls(0), TextBox)
            textItem3.TextMode = TextBoxMode.MultiLine
            textItem3.Wrap = True
            textItem3.Width = 300
            textItem3.Style.Add("border", "1px solid #CCCCCC")
            textItem3.Style.Add("font", "10pt tahoma,sans-serif")
            textItem3.Rows = 10
            textItem3.Text = textItem3.Text.Replace("<br/>", Chr(10))
 
            Dim textItem4 As TextBox = DirectCast(item("ProposedMitigation").Controls(0), TextBox)
            textItem4.TextMode = TextBoxMode.MultiLine
            textItem4.Wrap = True
            textItem4.Width = 300
            textItem4.Style.Add("border", "1px solid #CCCCCC")
            textItem4.Style.Add("font", "10pt tahoma,sans-serif")
            textItem4.Rows = 10
            textItem4.Text = textItem4.Text.Replace("<br/>", Chr(10))
 
            Dim textItem5 As TextBox = DirectCast(item("ImplementationPlan").Controls(0), TextBox)
            textItem5.TextMode = TextBoxMode.MultiLine
            textItem5.Wrap = True
            textItem5.Width = 150
            textItem5.Style.Add("border", "1px solid #CCCCCC")
            textItem5.Style.Add("font", "10pt tahoma,sans-serif")
            textItem5.Rows = 10
            textItem5.Text = textItem5.Text.Replace("<br/>", Chr(10))
 
 
        End If
 
    End Sub
 
    Protected Sub RadGrid1_ItemInserted(ByVal source As Object, ByVal e As Telerik.Web.UI.GridInsertedEventArgs) Handles RadGrid1.ItemInserted
        If Not e.Exception Is Nothing Then
            e.ExceptionHandled = True
            e.KeepInInsertMode = True
            SetMessage("Product cannot be inserted. Reason: " + e.Exception.Message)
        Else
            SetMessage("New product is inserted!")
        End If
    End Sub
 
    Protected Sub RadGrid1_ItemUpdated(ByVal source As Object, ByVal e As Telerik.Web.UI.GridUpdatedEventArgs) Handles RadGrid1.ItemUpdated
        Dim item As GridEditableItem = DirectCast(e.Item, GridEditableItem)
        Dim id As String = item.GetDataKeyValue("ID").ToString()
 
        If Not e.Exception Is Nothing Then
            e.KeepInEditMode = True
            e.ExceptionHandled = True
            SetMessage("Risk " + id + " cannot be updated. Reason: " + e.Exception.Message)
        Else
            SetMessage("Risk " + id + " is updated!")
        End If
    End Sub
 
    Private Sub DisplayMessage(ByVal text As String)
        RadGrid1.Controls.Add(New LiteralControl(String.Format("<span style='color:red'>{0}</span>", text)))
    End Sub
 
    Private Sub SetMessage(ByVal message As String)
        gridMessage = message
    End Sub
 
    Private gridMessage As String = Nothing
 
    Protected Sub RadGrid1_DataBound(ByVal sender As Object, ByVal e As EventArgs) Handles RadGrid1.DataBound
        If Not String.IsNullOrEmpty(gridMessage) Then
            DisplayMessage(gridMessage)
        End If
    End Sub
 
End Class
Candice
Top achievements
Rank 1
 answered on 08 Dec 2011
7 answers
487 views
Hi,

I have a scenario where I need to loop through the number of rows in the detail table for each row and read the columns in the detail table.

I am binding my grid to a datasource with the relation defined.
I am unable to read the child rows in my ItemDataBound event. I tried using dataItem.childItem but my child Item always comes null.

I am not sure my detail table is getting any data or not.
I don't want to show my detail table to the user just want to read the values in the detail table.

Below is how my detail table is defined:
<MasterTableView TableLayout="Fixed" HierarchyDefaultExpanded="true" CommandItemDisplay="Top"
                        EnableNoRecordsTemplate="true">                                             
                        <Columns>
                            ......
                        </Columns>
                        <DetailTables>
                            <telerik:GridTableView DataKeyNames="AccountID" Width="100%" DataMember="FundBalance" HierarchyLoadMode="ServerBind">
                                <ParentTableRelation>
                                    <telerik:GridRelationFields DetailKeyField="AccountID" MasterKeyField="AccountID" />
                                </ParentTableRelation>
                                <Columns>
                                    <telerik:GridBoundColumn DataField="AccountID" UniqueName="AccountID">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn DataField="FundTypeID" UniqueName="FundTypeID">
                                    </telerik:GridBoundColumn>                                   
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn UniqueName="BeginBalanceShares" DataField="BeginBalanceShares">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn UniqueName="BeginPrice" DataField="BeginPrice" >
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn UniqueName="BeginBalanceDollars" DataField="BeginBalanceDollars">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn UniqueName="EndBalanceShares" DataField="EndBalanceShares">
                                    </telerik:GridBoundColumn>
                                </Columns>
                            </telerik:GridTableView>
                        </DetailTables>
                    </MasterTableView>
 
 
My datasource is defined as:
 
public static DataTable ListByPlanAndDateRange(int planID, DateTime beginDate, DateTime endDate)
        {
            DataSet ds = DBRoutines.wusp_PeriodSummaryByFund_ListByPlanAndDateRange(planID, beginDate, endDate);
            ds.Tables[0].TableName = "FundBalance";
            ds.Tables[1].TableName = "SourceContribution";
            ds.Relations.Add("BalanceRelation", ds.Tables[0].Columns[Fields.FundID], ds.Tables[1].Columns[Fields.FundID], false);
            return ds.Tables[0];
        }

Basically I have a asp.net gridview to migrate from and currently I am using this to access the child rows:
protected void balances_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                DataRowView drv = (DataRowView)e.Row.DataItem;
                DataRow[] drSubBalance = drv.Row.GetChildRows("BalanceRelation");
            }
        }
I want to do something similar in radgrid.

I have spent 2 days trying to figure this out. Please provide some help!
MBEN
Top achievements
Rank 2
Veteran
 answered on 07 Dec 2011
6 answers
188 views
I'm following your demo called Grid Heirachy with Templates. It shows a list of sales people and if you click the left column down arrow, it displays 3 tabs (sales, contact info, chart), each tab is designed with a RadPageView. It does work. However, the problem I have is when you load the page it executes the all queries to the database for each tab for every visible employee in the grid, all on page load. So if I have 50 rows in the main grid and 3 tabs (with scrolling enalbed naturally), 150 queries get executed all at once. This can be very bad for performance especially if I increase the rows on the main grid to a much higher number (which is what I need to do). I plan to show about 100 rows of data, plus add a few more tabs totaling 5 tabs of information, so I'd have 500 queries execute all on page load! on every postback too!

Not only is this a performance issue, it's also a stale data issue. If it's a highly active database with lots of inserts/updates going on, a grid user might wait 20 minutes, click the down arrow and see the orders with out-of-date information since a person somewhere else in the company might have since edited many rows of that order data for that sales person. 

The solution is: Those 3 sub tabs should only execute their queries when the user clicks the down arrow to make them visible, per employee. How can that be accomplished?

Thank you.
David
Top achievements
Rank 1
 answered on 07 Dec 2011
7 answers
214 views
I created the menu programmatically.
and I've a problem with some witdh of group. I need change the width of somes groups.

Attach an image

How I can fix this?
I try with:
-  group.Style.add(.....Width, "100px") but does not work.
- by css .RadRibbonBar .rrbMenuGroupIn {
    padding: 1px 20px 1px 20px;
}but does not work.

I need a quickly solution for not change a all code,

regards
July
Top achievements
Rank 2
 answered on 07 Dec 2011
1 answer
84 views
Does the RadGrid webpart support creating a heirarchy when the child item resides in a folder and if so how does one turn that setting on? An initial out of the box example I have tried does not seem to allow for this, all items returns must be at the root of the Sharepoint list.

Jon
Tsvetoslav
Telerik team
 answered on 07 Dec 2011
1 answer
225 views

Dear all,

I have a user control with (RadAjaxProxyManager) and the (RadAjaxManager) on the ASP.NET page where the user control lives 

I need to put the below JS function isnide .JS file not on the page directly. I want to get rid of the RadCodeBlock tag as well I'm combining JS in files. I dont want to have inline JS functions on ASP.NET pages.

<rad:RadCodeBlock ID="RadCodeBlock1" runat="server">
<script type="text/javascript">
 function refreshAttachmentGrid(arg) {
$find("<%= RadAjaxManager.GetCurrent(Page).ClientID %>").ajaxRequest("RefreshAttachment");
}
</script>
</rad:RadCodeBlock>


The code works fine, all I need is to move it to JS file.

Thanks in advance.

Taiseer

Andrey
Telerik team
 answered on 07 Dec 2011
5 answers
229 views
Will there be any tutorials of how to integrate asp.net controls with kendoui

cheers

Jason
Sebastian
Telerik team
 answered on 07 Dec 2011
1 answer
154 views
IS IT POSSIBLE TO SHOW RELATED DATA OF EACH SLICE IN PIE CHART.LIKE CLICK EVENTS
Giuseppe
Telerik team
 answered on 07 Dec 2011
13 answers
222 views
Hello,

I am using RadDatePicker and having the width issue..no matter how much i fix it it always takes up the whole page space....http://www.telerik.com/community/forums/aspnet-ajax/input/raddatepicker-calendar-width.aspx..having a similar issue as is mentioned in this thread but in the end part someone said that it is solved in the next release I have the latest version of telerik

2011.2.712.35  but am still having this issue..It works fine in firefox,chrome but not in IE8...
Can someone please help me with this.

Thanks


Keith
Top achievements
Rank 1
 answered on 07 Dec 2011
4 answers
259 views

Hello everyone and special thanks to Princy!

I am using a Radgrid with a Radwindow on Editing , you can see all about it in “Demo/Asp.Net Ajax/Window/Edit Dialog For RadGrid”

I tried it to customize it  in my Project logic and every thing is fine when I use the same structure(DefaultCS.aspx, and code behind and EditForm and its codebehind).

But  I am using a UserControl instead of aspx file ,as follow :

Root

.

.

.

Folder :Usercontrols

                                                ChargePanel.ascx(Instead of DefaultCS.aspx)[Inherited from SiteMasterpage]

                                                EditForm.aspx  

SiteMasterPage.master

 

When I click On Edit Button everything is true still, and works fine ,and the Grid will be updated after closing windows with some Java Script Code,after do that if I tend to edit another row when I click the Edit button It will raise  an error!

                Microsoft JScript runtime error: 'null' is null or not an object

 

Here is my Code,I have  tried  to find a solution from Many posts but I didn’t find anything to help me…

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="ChargePanelCS.ascx.cs"
    Inherits="UserControls_ChargePanel" %>
<telerik:RadCodeBlock ID="RadCodeBlock2" runat="server">
    <style type="text/css">
        .orderText
        {
            font: normal 12px Arial,Verdana;
            margin-top: 6px;
        }
        .expandImage
        {
            display: inline-block;
            background-image: url('<%= Page.ResolveUrl("~/Common/styles09/sprite09.gif")%>');
            background-position: -596px -1191px;
            background-repeat: no-repeat;
            width: 15px;
            height: 15px;
        }
        * html .expandImage
        {
            background-position: -596px -1194px;
        }
        * + html .expandImage
        {
            background-position: -596px -1194px;
        }
    </style>
</telerik:RadCodeBlock>
<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
    <script type="text/javascript">
        function ShowEditForm(id, rowIndex) {
            var grid = $find("<%= RadGrid1.ClientID %>");
 
            var rowControl = grid.get_masterTableView().get_dataItems()[rowIndex].get_element();
            grid.get_masterTableView().selectItem(rowControl, true);
 
            window.radopen("../UserControls/EditFormCS.aspx?PanelId=" + id, "UserListDialog");
            return false;
        }
        function ShowInsertForm() {
            window.radopen("../UserControls/EditFormCS.aspx", "UserListDialog");
            return false;
        }
        function refreshGrid(arg) {
            if (!arg) {
                $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("Rebind");
            }
            else {
                $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("RebindAndNavigate");
            }
        }
        function RowDblClick(sender, eventArgs) {
            window.radopen("../UserControls/EditFormCS.aspx?PanelId=" + eventArgs.getDataKeyValue("PanelId"), "UserListDialog");
        }
    </script>
</telerik:RadCodeBlock>
   <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" OnAjaxRequest="RadAjaxManager1_AjaxRequest">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="RadAjaxManager1">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="RadGrid1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
                <telerik:AjaxSetting AjaxControlID="RadGrid1">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="RadGrid1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>
        <telerik:RadGrid ID="RadGrid1" runat="server" CssClass="myRadGrid" AllowPaging="true"
            AllowSorting="true" OnNeedDataSource="RadGrid1_NeedDataSource" PageSize="10"
            Font-Names="Tahoma" dir="rtl" AllowFilteringByColumn="true" OnUpdateCommand="RadGrid1_UpdateCommand"
            OnItemCreated="RadGrid1_ItemCreated">
            <ExportSettings IgnorePaging="true" OpenInNewWindow="true">
                <Pdf PageHeight="297mm" PageWidth="210mm" PageTitle="SushiBar menu" />
            </ExportSettings>
            <MasterTableView AutoGenerateColumns="False" CommandItemDisplay="Top" TableLayout="Auto"
                Font-Names="Tahoma" DataKeyNames="PanelId" EditMode="PopUp">
                <%--<EditFormSettings InsertCaption="ركورد جديد" CaptionFormatString="ويرايش" CaptionDataField="PanelId"
            PopUpSettings-Modal="true" FormCaptionStyle-Font-Names="Tahoma" EditColumn-HeaderStyle-Font-Names="Tahoma" />--%>
                <CommandItemTemplate>
                    <div style="padding: 5px 5px;" dir="rtl">
                        <asp:LinkButton ID="LinkButton4" runat="server" Font-Names="Tahoma" CommandName="RebindGrid"><img style="border:0px;vertical-align:middle;" alt="" src="../Images/Icons/Refresh.gif" />به روزآوري اطلاعات</asp:LinkButton>
                    </div>
                </CommandItemTemplate>
                <Columns>
                    <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn">
                        <ItemStyle CssClass="MyImageButton" />
                    </telerik:GridEditCommandColumn>
                    <telerik:GridBoundColumn AllowSorting="true" DataField="PanelName" HeaderText="نام پنل"
                        SortExpression="PanelName" UniqueName="PanelName" ColumnEditorID="GridTextBoxColumn">
                    </telerik:GridBoundColumn>
                    <telerik:GridTemplateColumn HeaderText="رده بندي ارسال">
                        <ItemTemplate>
                            <telerik:RadRating dir="rtl" ID="RadRating1" runat="server" AutoPostBack="true" Value='<%# Convert.ToDouble(Eval("Used_Charges_Send"))/100000 %>'
                                OnRate="RadRating1_Rate" ReadOnly="true" Precision="Item" ItemCount="10" />
                        </ItemTemplate>
                    </telerik:GridTemplateColumn>
                    <telerik:GridBoundColumn AllowSorting="true" DataField="N_Charges_Send" HeaderText="شارژ ارسال"
                        SortExpression="N_Charges_Send" UniqueName="N_Charges_Send" ItemStyle-CssClass="grid_txt_NO"
                        ColumnEditorID="GridTextBoxColumn">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn AllowSorting="true" DataField="Fake_Charges_Send" HeaderText="شارژ اضطراري"
                        SortExpression="Fake_Charges_Send" UniqueName="Fake_Charges_Send" ItemStyle-CssClass="grid_txt_NO"
                        ColumnEditorID="GridTextBoxColumn">
                    </telerik:GridBoundColumn>
                    <telerik:GridTemplateColumn UniqueName="TemplateEditColumn">
                        <ItemTemplate>
                            <asp:HyperLink ID="EditLink" runat="server" ToolTip="افزايش شارژ" ImageUrl="../Images/Icons/Credit.png"
                                Text="Charge"></asp:HyperLink>
                        </ItemTemplate>
                    </telerik:GridTemplateColumn>
                </Columns>
                <PagerStyle Mode="NumericPages" />
                <EditFormSettings ColumnNumber="3" CaptionDataField="PanelId" CaptionFormatString="ويرايش اطلاعات"
                    InsertCaption="" FormCaptionStyle-Font-Names="Tahoma" FormStyle-Font-Names="Tahoma">
                    <FormTableItemStyle Wrap="True"></FormTableItemStyle>
                    <FormCaptionStyle CssClass="EditFormHeader"></FormCaptionStyle>
                    <FormMainTableStyle GridLines="None" CellSpacing="5" BorderColor="Yellow" CellPadding="3"
                        Width="100%" />
                    <FormTableStyle CellSpacing="0" CellPadding="2" Height="110px" Font-Names="Tahoma" />
                    <FormTableAlternatingItemStyle Wrap="False"></FormTableAlternatingItemStyle>
                    <EditColumn ButtonType="ImageButton" InsertText="ثبت " UpdateText="ويرايش" UniqueName="EditCommandColumn1"
                        CancelText="لغو ">
                    </EditColumn>
                    <FormTableButtonRowStyle HorizontalAlign="Right" CssClass="EditFormButtonRow"></FormTableButtonRowStyle>
                </EditFormSettings>
            </MasterTableView>
            <ClientSettings>
                <Selecting AllowRowSelect="true" />
                <ClientEvents OnRowDblClick="RowDblClick" />
            </ClientSettings>
        </telerik:RadGrid>
        <telerik:RadWindowManager ID="RadWindowManager1" runat="server" EnableShadow="true" OnClientClose="refreshGrid" >
            <Windows>
                <telerik:RadWindow ID="UserListDialog" runat="server" Title="Editing record" Height="320px"
                    Width="310px" Left="150px" ReloadOnShow="true" ShowContentDuringLoad="false"
                    Modal="true" />
            </Windows>
        </telerik:RadWindowManager>
        <telerik:GridTextBoxColumnEditor ID="GridTextBoxColumn" runat="server" TextBoxStyle-CssClass="GridTextBoxColumnEditor" />
        <asp:Label ID="Label1" runat="server" Width="410px"></asp:Label>
    </div>
    <!-- content end -->
    </form>
</body>
</html>
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
   {
     
       if (e.Item is GridDataItem)
       {
           HyperLink editLink = (HyperLink)e.Item.FindControl("EditLink");
           editLink.Attributes["href"] = "#";
           editLink.Attributes["onclick"] = String.Format("return ShowEditForm('{0}','{1}');", e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["PanelId"], e.Item.ItemIndex);
       }
   }
protected void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e)
   {
       if (e.Argument == "Rebind")
       {
           RadGrid1.MasterTableView.SortExpressions.Clear();
           RadGrid1.MasterTableView.GroupByExpressions.Clear();
           RadGrid1.Rebind();
       }
       else if (e.Argument == "RebindAndNavigate")
       {
           RadGrid1.MasterTableView.SortExpressions.Clear();
           RadGrid1.MasterTableView.GroupByExpressions.Clear();
           RadGrid1.MasterTableView.CurrentPageIndex = RadGrid1.MasterTableView.PageCount - 1;
           RadGrid1.Rebind();
       }
   }
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="EditFormCS.aspx.cs" Inherits="UserControls_EditFormCS" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head id="Head1" runat="server">
    <title>Edit dialog</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <script type="text/javascript">
            function CloseAndRebind(args) {
                GetRadWindow().BrowserWindow.refreshGrid(args);
                GetRadWindow().close();
            }
 
            function GetRadWindow() {
                var oWindow = null;
                if (window.radWindow) oWindow = window.radWindow; //Will work in Moz in all cases, including clasic dialog
                else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow; //IE (and Moz as well)
 
                return oWindow;
            }
 
            function CancelEdit() {
                GetRadWindow().close();
            }
            function onError(input, args) {
                var message = "Invalid character: ";
 
                message += "accepts only numberic values.";
                document.getElementById("numInput").innerHTML = args.get_inputText();
                document.getElementById("numErrorOut").innerHTML = message;
            }
            function onKeyPress(input, args) {
 
                document.getElementById("numInput").innerHTML = "";
                document.getElementById("numErrorOut").innerHTML = "";
 
            }
            function Close() {
                GetRadWindow().Close();
            }
        </script>
        <asp:ScriptManager ID="ScriptManager2" runat="server" />
        <telerik:RadFormDecorator ID="RadFormDecorator1" runat="server" DecoratedControls="All" />
        <br />
        <br />
        <telerik:RadNumericTextBox ID="RadNumericTextBox1" runat="server" Type="Number" NumberFormat-DecimalDigits="0">
            <ClientEvents OnError="onError" OnKeyPress="onKeyPress"></ClientEvents>
        </telerik:RadNumericTextBox>
        <asp:Button runat="server" Text="Submit" ID="btnSubmit" OnClick="Unnamed1_Click" />
        <asp:Button runat="server" Text="Reset" ID="btnReset" OnClick="btnReset_Click" Visible="false" />
    </div>
    <asp:Label ID="Label1" runat="server" Width="410px"></asp:Label>
    <div class="module" style="width: 448px; clear: both;">
        <table cellpadding="4" cellspacing="0" width="100%">
            <tbody>
                <tr>
                    <td>
                        <span id="numInput"></span>
                    </td>
                    <td>
                        <span id="numErrorOut" style="color: Red"></span>
                    </td>
                </tr>
            </tbody>
        </table>
    </div>
    </form>
</body>
</html>
protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);
 
       
        this.Page.Title = "Editing record";
    }
protected void btnSubmit_Click(object sender, EventArgs e)
    {
 
        //Some Code here
 
       Label1.Text = "<script type='text/javascript'>Close()</" + "script>";
        
        }
 
 
 
 
 
    }
    protected void btnReset_Click(object sender, EventArgs e)
    {
       /SomeCode here
    }

L D
Top achievements
Rank 1
 answered on 07 Dec 2011
Narrow your results
Selected tags
Tags
+? more
Top users last month
Hiba
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Max
Top achievements
Rank 1
Veteran
Iron
Alina
Top achievements
Rank 1
Rakhee
Top achievements
Rank 1
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Hiba
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Max
Top achievements
Rank 1
Veteran
Iron
Alina
Top achievements
Rank 1
Rakhee
Top achievements
Rank 1
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?