Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
84 views

Hello, I have the following requirements for enhancing a radgrid on a page on our website:

 

1. When the insert form is opened, the end user should only see the Date of Service and Status fields enabled.

2. Upon selecting a status, the other elements in the form should be updated based on the selected status

 

Here is how we have our radgrid set up in the aspx page:

 

<telerik:RadGrid ID="RadGrid2" ShowStatusBar="True" runat="server" AllowPaging="True" PageSize="5" DataSourceID="SqlDataSource2" AllowAutomaticDeletes="True" AllowAutomaticInserts="True" AllowAutomaticUpdates="True" ShowFooter="True" Skin="Silk" ShowHeader="False" AllowSorting="True">
        <MasterTableView Width="100%" AutoGenerateColumns="False" DataSourceID="SqlDataSource2" CommandItemDisplay="Top" ShowFooter="False" EditMode="PopUp" DataKeyNames="VisitsID" ShowHeader="True" InsertItemPageIndexAction="ShowItemOnCurrentPage">
            <EditFormSettings PopUpSettings-Height="400px" PopUpSettings-Width="810px">
                <EditColumn UniqueName="EditCommandColumn1" FilterControlAltText="Filter EditCommandColumn column"/>
                <PopUpSettings Modal="True" Height="400px" Width="810px" ScrollBars="Vertical"/>
            </EditFormSettings>          
 
            <CommandItemSettings ExportToPdfText="Export to PDF" AddNewRecordText="Add new visit"/>
            <RowIndicatorColumn Visible="True" FilterControlAltText="Filter RowIndicator column"/>
            <ExpandCollapseColumn Visible="True" FilterControlAltText="Filter ExpandColumn column"/>
      
            <Columns>
                <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn">
                    <ItemStyle CssClass="MyImageButton" />
                </telerik:GridEditCommandColumn>        
                 
                <telerik:GridBoundColumn DataField="ClaimsID" DataType="System.Int32" FilterControlAltText="Filter ClaimsID column" HeaderText="ClaimsID" ReadOnly="True" SortExpression="ClaimsID" UniqueName="ClaimsID" Visible="False"/>               
                <telerik:GridBoundColumn DataField="FirstName" FilterControlAltText="Filter FirstName column" HeaderText="Name" SortExpression="FirstName" UniqueName="FirstName" ReadOnly="True"/>               
                <telerik:GridDateTimeColumn DataField="DOS" FilterControlAltText="Filter DOS column" HeaderText="DOS" SortExpression="DOS" DataFormatString = "{0:d}" UniqueName="DOS" DataType="System.DateTime">
                    <ColumnValidationSettings EnableRequiredFieldValidation="True">
                        <RequiredFieldValidator Display="Dynamic" ErrorMessage="DOS is Required!" Font-Bold="True" ForeColor="Red" SetFocusOnError="True"/>
                    </ColumnValidationSettings>
               </telerik:GridDateTimeColumn>               
                
               <telerik:GridDropDownColumn DataSourceID="SqlDataSource4" ListTextField="Units" ListValueField="Units" UniqueName="Units" SortExpression="Units" HeaderText="Units" DataField="Units" DropDownControlType="RadComboBox" FooterText="RadComboBox column footer" AllowAutomaticLoadOnDemand="false" AllowVirtualScrolling="true" ShowMoreResultsBox="true" ItemsPerRequest="10"/>              
               <telerik:GridDropDownColumn DataSourceID="SqlDataSource6"  ListTextField="DDDDescription" ListValueField="DDDCode" FilterControlAltText="Filter DDDCode column" HeaderText="Code" DataField="DDDCode" SortExpression="DDDCode" UniqueName="DDDCode" DropDownControlType="RadComboBox"  FooterText="RadComboBox column footer" AllowAutomaticLoadOnDemand="false" AllowVirtualScrolling="true" ShowMoreResultsBox="true" ItemsPerRequest="10"/>              
               <telerik:GridDropDownColumn DataSourceID="SqlDataSource7"  ListTextField="VisitStatus" ListValueField="VisitStatus" FilterControlAltText="Filter Status column" HeaderText="Status" DataField="VisitStatus" SortExpression="VisitStatus" UniqueName="VisitStatus" DropDownControlType="RadComboBox"  FooterText="RadComboBox column footer" AllowAutomaticLoadOnDemand="false" AllowVirtualScrolling="true" ShowMoreResultsBox="true" ItemsPerRequest="10"/>              
               <telerik:GridBoundColumn DataField="TherapistID" FilterControlAltText="Filter TherapistID column" HeaderText="TherapistID" SortExpression="TherapistID" UniqueName="TherapistID" Visible="False"/>              
               <telerik:GridBoundColumn DataField="PatientID" FilterControlAltText="Filter PatientID column" HeaderText="PatientID" SortExpression="PatientID" UniqueName="PatientID" DataType="System.Int32" Visible="False"/>              
               <telerik:GridTemplateColumn HeaderText="Subjective" UniqueName="Subjective">
                    <EditItemTemplate>
                        <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Subjective") %>' TextMode="MultiLine" Height="70px" Width="700px" Wrap="True"/>
                        <asp:CustomValidator id="custV" runat="server" ControlToValidate = "TextBox1" ErrorMessage = "Minimum of 25 characters required" ClientValidationFunction="MinLength"/>
                        <asp:RequiredFieldValidator id="RequiredFieldValidator1" ControlToValidate="TextBox1" Text="Subjective Is Required" runat="server"/>
                     </EditItemTemplate>
 
                     <ItemTemplate>
                        <asp:Label ID="Label1" runat="server" Text='<%# Eval("Subjective") %>'/>
                     </ItemTemplate>                  
                </telerik:GridTemplateColumn>
                 
                <telerik:GridTemplateColumn HeaderText="Objective" UniqueName="Objective" >
                    <EditItemTemplate>
                        <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("Objective") %>' TextMode="MultiLine" Height="70px" Width="700px"/>
                        <asp:CustomValidator id="custV2" runat="server" ControlToValidate = "TextBox2" ErrorMessage = "Minimum of 25 characters required" ClientValidationFunction="MinLength"/>
                        <asp:RequiredFieldValidator id="RequiredFieldValidator2" ControlToValidate="TextBox2" Text="Objective Is Required" runat="server"/>
                     </EditItemTemplate>
                      
                     <ItemTemplate>
                        <asp:Label ID="Label2" runat="server" Text='<%# Eval("Objective") %>'/>
                     </ItemTemplate>                      
                </telerik:GridTemplateColumn>               
 
                <telerik:GridTemplateColumn HeaderText="Assessment" UniqueName="Assessment" >
                    <EditItemTemplate>
                        <asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("Assessment") %>' TextMode="MultiLine" Height="70px" Width="700px"/>
                        <asp:CustomValidator id="custV3" runat="server" ControlToValidate = "TextBox3" ErrorMessage = "Minimum of 25 characters required" ClientValidationFunction="MinLength"/>
                        <asp:RequiredFieldValidator id="RequiredFieldValidator3" ControlToValidate="TextBox3" Text="Assessment Is Required" runat="server"/>
                    </EditItemTemplate>
                     
                    <ItemTemplate>
                        <asp:Label ID="Label3" runat="server" Text='<%# Eval("Assessment") %>'/>
                    </ItemTemplate>                       
                </telerik:GridTemplateColumn>
 
                <telerik:GridTemplateColumn HeaderText="Plan" UniqueName="Plann" >
                    <EditItemTemplate>        
                        <asp:TextBox ID="TextBox4" runat="server" Text='<%# Bind("Plann") %>' TextMode="MultiLine" Height="70px" Width="700px"/>
                        <asp:CustomValidator id="custV4" runat="server" ControlToValidate = "TextBox4" ErrorMessage = "Minimum of 25 characters required" ClientValidationFunction="MinLength"/>
                        <asp:RequiredFieldValidator id="RequiredFieldValidator4" ControlToValidate="TextBox4" Text="Plan Is Required" runat="server"/>
                    </EditItemTemplate>
 
                    <ItemTemplate>
                        <asp:Label ID="Label4" runat="server" Text='<%# Eval("Plann") %>'></asp:Label>
                    </ItemTemplate>                     
                </telerik:GridTemplateColumn>
 
                <telerik:GridBoundColumn DataField="UserName" FilterControlAltText="Filter UserName column" HeaderText="UserName" SortExpression="UserName" UniqueName="UserName" Visible="False" ReadOnly="True"/>
                <telerik:GridButtonColumn ConfirmText="Are you sure you want to delete this visit?" ConfirmDialogType="RadWindow" ConfirmTitle="Delete" ButtonType="ImageButton" CommandName="Delete" Text="Delete" UniqueName="DeleteColumn">
                     <ItemStyle HorizontalAlign="Center" CssClass="MyImageButton" />
                </telerik:GridButtonColumn>
           </Columns>
 
           <EditFormSettings UserControlName="Home Health Billing">
                <EditColumn FilterControlAltText="Filter EditCommandColumn column"/>
                <PopUpSettings Modal="True" />                         
            </EditFormSettings>
             
            <PagerStyle AlwaysVisible="True"  />          
        </MasterTableView>
 
        <ClientSettings AllowKeyboardNavigation="true" EnablePostBackOnRowClick="true">
            <ClientEvents OnPopUpShowing="PopUpShowing" />
            <Selecting AllowRowSelect="true" />
        </ClientSettings>
 
        <PagerStyle Mode="Advanced" AlwaysVisible="True" />
        <FilterMenu EnableImageSprites="False"/>
    </telerik:RadGrid>

 

I have already attempting using OnItemCommand and checking for InitInsert but during this time the ItemCommandArgs.Item attribute is not a GridDataItem of any kind, it always spits out a cast error when trying to cast it to get at the columns to modify them as per our requirements.

 

The crux of it is that some way, either once the initinsert command has been issues or when the popup modal open command is issues we need to get into the popup window and make changes and then we also need to make changes when the status is changed.

 

How would we access the open popup modal from an OnSelectedIndexChanged sub?  My first guess would be getting the tableview through the owner of the sender parameter but that will only be applicable if the controls in the popup can remain grid elements.

 

Is something that can be done with a RadGrid or will we need to re-engineer the page to implement this?

 

Thanks.

Attila Antal
Telerik team
 answered on 16 Jan 2019
8 answers
718 views
Hi,

I'm new using the telerik's controls so I need some help. Let's start also saying that the controls that we have are the trials controls because we are in the process of buying them

We have a multi-tier application, the asp.net client, a bunch WCF services and the Entity framework to access the DB, the client to access the data must go thru the WCF services. We are evaluating the RADGRID to see how it integrates in this environment without doing a lot of changes in our code. All the Grid will have multicolumn filtering and sorting.

What I been trying to do is to implement the Sorting and filtering, this looks very easy when the grid is connected to the database but I can't find any examples of how to do it in a custom way, meaning I want to retrieve the filtering and sorting expressions from the grid, send these as parameters to the WCF service, retrieve the data and then bind the results into the grid again.

When i try to do this just by storing the initial retrieved rows from the DB into the session and then in the ItemCommand event just rebind the grid with those same results I get the following error :

Expression expected

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: Telerik.Web.UI.ParseException: Expression expected

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[ParseException: Expression expected]
   Telerik.Web.UI.ExpressionParser.ParsePrimaryStart() +227
   Telerik.Web.UI.ExpressionParser.ParsePrimary() +36
   Telerik.Web.UI.ExpressionParser.ParseUnary() +404
   Telerik.Web.UI.ExpressionParser.ParseMultiplicative() +54
   Telerik.Web.UI.ExpressionParser.ParseAdditive() +54
   Telerik.Web.UI.ExpressionParser.ParseComparison() +69
   Telerik.Web.UI.ExpressionParser.ParseLogicalAnd() +49
   Telerik.Web.UI.ExpressionParser.ParseLogicalOr() +49
   Telerik.Web.UI.ExpressionParser.ParseExpression() +60
   Telerik.Web.UI.ExpressionParser.ParseArguments() +68
   Telerik.Web.UI.ExpressionParser.ParseArgumentList() +96
   Telerik.Web.UI.ExpressionParser.ParseIif() +58
   Telerik.Web.UI.ExpressionParser.ParseIdentifier() +234
   Telerik.Web.UI.ExpressionParser.ParsePrimaryStart() +65
   Telerik.Web.UI.ExpressionParser.ParsePrimary() +36
   Telerik.Web.UI.ExpressionParser.ParseUnary() +404
   Telerik.Web.UI.ExpressionParser.ParseMultiplicative() +54
   Telerik.Web.UI.ExpressionParser.ParseAdditive() +54
   Telerik.Web.UI.ExpressionParser.ParseComparison() +69
   Telerik.Web.UI.ExpressionParser.ParseLogicalAnd() +49
   Telerik.Web.UI.ExpressionParser.ParseLogicalOr() +49
   Telerik.Web.UI.ExpressionParser.ParseExpression() +60
   Telerik.Web.UI.ExpressionParser.ParseParenExpression() +63
   Telerik.Web.UI.ExpressionParser.ParsePrimaryStart() +151
   Telerik.Web.UI.ExpressionParser.ParsePrimary() +36
   Telerik.Web.UI.ExpressionParser.ParseUnary() +404
   Telerik.Web.UI.ExpressionParser.ParseMultiplicative() +54
   Telerik.Web.UI.ExpressionParser.ParseAdditive() +54
   Telerik.Web.UI.ExpressionParser.ParseComparison() +69
   Telerik.Web.UI.ExpressionParser.ParseLogicalAnd() +49
   Telerik.Web.UI.ExpressionParser.ParseLogicalOr() +49
   Telerik.Web.UI.ExpressionParser.ParseExpression() +60
   Telerik.Web.UI.ExpressionParser.Parse(Type resultType) +58
   Telerik.Web.UI.DynamicExpression.ParseLambda(ParameterExpression[] parameters, Type resultType, String expression, Object[] values) +81
   Telerik.Web.UI.DynamicExpression.ParseLambda(Type itType, Type resultType, String expression, Object[] values) +114
   Telerik.Web.UI.GridDynamicQueryable.Where(IQueryable source, String predicate, Object[] values) +208
   Telerik.Web.UI.GridDataTableFromEnumerable.FillData35() +3835
   Telerik.Web.UI.GridDataTableFromEnumerable.FillData() +1064
   Telerik.Web.UI.GridResolveEnumerable.Initialize() +58
   Telerik.Web.UI.GridResolveEnumerable.EnsureInitialized() +45
   Telerik.Web.UI.GridResolveEnumerable.get_DataTable() +31
   Telerik.Web.UI.GridEnumerableFromDataView..ctor(GridTableView owner, IEnumerable enumerable, Boolean CaseSensitive, Boolean autoGenerateColumns, GridColumnCollection presentColumns, String[] additionalField, Boolean retrieveAllFields) +222
   Telerik.Web.UI.GridDataSourceHelper.CreateGridEnumerable(GridTableView owner, IEnumerable enumerable, Boolean caseSensitive, Boolean autoGenerateColumns, GridColumnCollection presentColumns, String[] additionalField, Boolean retrieveAllFields) +155
   Telerik.Web.UI.GridDataSourceHelper.GetResolvedDataSource(GridTableView owner, Object dataSource, String dataMember, Boolean caseSensitive, Boolean autoGenerateColumns, GridColumnCollection presentColumns, String[] additionalField, Boolean retrieveAllFields) +566
   Telerik.Web.UI.GridTableView.get_ResolvedDataSource() +224
   Telerik.Web.UI.GridTableView.CreateChildControls(IEnumerable dataSource, Boolean useDataSource) +73
   System.Web.UI.WebControls.CompositeDataBoundControl.PerformDataBinding(IEnumerable data) +66
   System.Web.UI.WebControls.DataBoundControl.OnDataSourceViewSelectCallback(IEnumerable data) +128
   System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +33
   System.Web.UI.WebControls.DataBoundControl.PerformSelect() +143
   Telerik.Web.UI.GridTableView.PerformSelect() +38
   System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +74
   Telerik.Web.UI.GridTableView.DataBind() +363
   Telerik.Web.UI.GridTableView.Rebind() +100
   Telerik.Web.UI.GridFilterCommandEventArgs.ExecuteCommand(Object source) +995
   Telerik.Web.UI.RadGrid.OnBubbleEvent(Object source, EventArgs e) +200
   System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37
   Telerik.Web.UI.GridItem.OnBubbleEvent(Object source, EventArgs e) +61
   System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37
   Telerik.Web.UI.GridItem.OnBubbleEvent(Object source, EventArgs e) +170
   Telerik.Web.UI.GridItem.FireCommandEvent(String commandName, Object commandArgument) +80
   Telerik.Web.UI.RadGrid.RaisePostBackEvent(String eventArgument) +9053
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +176
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5563


Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1


What am I doing wrong?, it looks very simple to me

Thanks for any help in advance
Attila Antal
Telerik team
 answered on 16 Jan 2019
2 answers
146 views

     I'm using telerik HTML 5 chart in the page which gets rendered along with bunch of other tables. so the page contains few tables, couple of paragraphs and telerik HTML5 charts in between them. 

I'm using this https://demos.telerik.com/aspnet-ajax/htmlchart/examples/functionality/responsive-chart/defaultvb.aspx link as reference for resizing the window. However when i try to do print the charts are not getting resized.

 

I'm using Area chart and Bar chart https://demos.telerik.com/aspnet-ajax/htmlchart/examples/charttypes/areachart/defaultvb.aspx 

 

But the resize on print doesnt work, can you help out with this issue? how to do print with resize feature, so that the chart doesnt get cutoff. Any help will be highly appreciated.

Lucy
Top achievements
Rank 1
 answered on 15 Jan 2019
6 answers
142 views

I need the MS Help Viewer installer download but can't find it in the list of downloads. Where can I get this? The web documentation is too difficult to use.

I'm using version 2016.1.225 of the asp.net ajax controls.

This is the page I have found and it refers to an installer download that I can't find.

"Installing local documentation for MS Help viewer (Help3) in Visual Studio 2010"

https://www.telerik.com/support/kb/aspnet-ajax/details/installing-local-documentation-for-ms-help-viewer-(help3)-in-visual-studio-2010

(I'm using visual studio 2013 but that may not matter)

 

Rumen
Telerik team
 answered on 15 Jan 2019
5 answers
511 views
Hello,

I have radnumeric textbox in my page and on mousescroll it is showing values moving up and down.

I dont want users to enter values on mouse scroll. I want them to  manually enter the values.

How to stop this cool feature ?

TIA 
Rumen
Telerik team
 answered on 15 Jan 2019
2 answers
109 views

I created a new project, and added a RadDropDownList to the form. I went into the configuration of the DDL, and tried to add a new datasource to an accdb database.

I clicked <new data source>, selected SQL database as the type, named the source and clicked OK.

On the Choose data connection page, I selected new connection. In the next page, i selected Microsoft Access Database File, and the always use this selection checkbox was checked.

I clicked continue.

In the Add connection dialog, I clicked browse for my database file name, and selected the ACCDB. This database has no log in, so i cleared out the UserName of Admin.

At this point, no matter what I do - either click test connection or click OK, VS2017 crashes with no error, just "Microsoft Visual Studio 2017 has stopped working".

I have tried this multiple times with the same result.

Can someone help please?

Jerry

Rumen
Telerik team
 answered on 15 Jan 2019
3 answers
287 views

I am developing a 2 level hierarchy radgrid.

The Parent grid is populated by importing a csv file's data.

The child grid is supposed to be populated by custom function i call from code behind.

The issue is that the detailtables is not displaying any data although in "e.DetailTableView.DataSource = dtF;" dtF (datatable) have the relevant data.

importcsv.png shows the data that binds to the parent grid.

subject.png shows the detailsbind event.

dtF.png shows the data that need to be bound to child grid.

ui.png is the parent grid that is successfully bound. But on clicking the expand button, child table is not getting displayed although the datasource contains the data.

Eyup
Telerik team
 answered on 15 Jan 2019
4 answers
406 views
Hi,

I have a context menu that's inside of a .NET repeater and I'm trying to use the menu's show method when a repeater row is clicked on. The menu shows when a row is clicked but I'm having trouble binding the menu to that particular row - clicking on any row of the repeater causes the menu to be bound to the last row in the repeater. I was wondering if there is a way to do this?

The code is basically:

<asp:Repeater ID="Repeater1" runat="server" OnItemDataBound="rptSchedules_ItemDataBound">
<ItemTemplate>
<tr data='<%# Eval("ddd") %>' runat="server" id="trItemRow" onclick="javascript: showConMenu(this,event); return false;">
<td>
<%# GetFormattedDateDisplay(Eval("InTime"))%>
</td>
<td>
<%# GetFormattedDateDisplay(Eval("OutTime"))%>
</td>
</tr>
<telerik:RadContextMenu runat="server" ID="ctxRowMenu" OnItemClick="TelerikMenuItemClick"
OnClientItemClicked="Client_MenuClicked" OnClientLoad="conMenuLoad">
<Items>
<telerik:RadMenuItem Text="Add" runat="server" PostBack="true">
</Items>
<Targets>
<telerik:ContextMenuControlTarget ControlID="trItemRow" />
</Targets>
</telerik:RadContextMenu>
</ItemTemplate>
</asp:Repeater>

Thanks,
Bill
Sean
Top achievements
Rank 1
 answered on 14 Jan 2019
12 answers
701 views
I'd like know how to use CalculatedColumn in Batch Editing mode. The most common scenario is UnitPrice * Quantity = Total Price. 

CalculatedColumn works fine in first inquiry. But when grid in Batch Editing mode, the Calculated Column in Client side has no mechanism to  automatically calculate.  I try to update total price cell  by java code, but I found there is no way to find the element. 

Please kindly help me to implement this. 

With best regards

Jason
Eyup
Telerik team
 answered on 14 Jan 2019
1 answer
516 views
I have added UpdatePanel to include a grid in order to reflect some changes. However, when I click other buttons on the page to update some data and the grid will disappear after postback. 

I try to remove the UpdatePanel, then the grid will be shown and data will be shown on the grid. 

Here is my code. 

Mainly, when the page first comes in, the grid will be shown with data. However, when I click a button on the page to update some data, and the update should be shown on the grid. The page is a postback, however, when I do this, the grid will not be shown. 

I try to remove the UpdatePanel in , then when I click the button on the page to update data, the grid will be shown again. It seems the UpdatePanel has made the grid disappear. I need to keep the UpdatePanel and make the grid not disappeared after I click the button on the page and post back.

        <asp:UpdatePanel ID="UpdatePanel3" runat="server">
       <ContentTemplate>
          <telerik:RadGrid ID="uiGrid" runat="server"
             AutoGenerateColumns="false" ItemStyle-BackColor="White" AlternatingItemStyle-BackColor="White"
             OnDataBound="uiGrid_DataBound" OnItemDataBound="uiGrid_ItemDataBound" OnNeedDataSource="uiGrid_NeedDataSource"
             ClientSettings-ClientEvents-OnKeyPress="keyPressInGrid"
             Width="100%" Height="500" EnableViewState="true">
             <ClientSettings>
                <Scrolling CountGroupSplitterColumnAsFrozen="false" AllowScroll="true" UseStaticHeaders="True" SaveScrollPosition="true" FrozenColumnsCount="3"></Scrolling>
             </ClientSettings>
             <MasterTableView>
                <GroupByExpressions>
                   <telerik:GridGroupByExpression>
                      <SelectFields>
                         <telerik:GridGroupByField FieldAlias="<%$ Resources:Resource,Group %>" FieldName="IndicatorParentName"></telerik:GridGroupByField>
                      </SelectFields>
                      <GroupByFields>
                         <telerik:GridGroupByField FieldName="IndicatorParentName" SortOrder="Ascending"></telerik:GridGroupByField>
                      </GroupByFields>
                   </telerik:GridGroupByExpression>
                </GroupByExpressions>
                <Columns>
                   <telerik:GridBoundColumn DataField="IndicatorName" HeaderText="<%$ Resources:Resource,Indicator %>" UniqueName="IndicatorName"
                      SortExpression="IndicatorName" DataType="System.String" ItemStyle-Wrap="false">
                   </telerik:GridBoundColumn>
                   <telerik:GridTemplateColumn>
                      <ItemTemplate>
                         <asp:HiddenField ID="uiIndicatorID" runat="server" Value='<%#Eval("IndicatorID")%>' />
                         <asp:HiddenField ID="uiIndicatorName" runat="server" Value='<%#Eval("IndicatorName")%>' />
                         <asp:ImageButton ID="uiTipsButton" runat="server" ImageUrl="images/information-icon.png?20170703" Width="16" Height="16" />
                      </ItemTemplate>
                   </telerik:GridTemplateColumn>
                   <telerik:GridTemplateColumn HeaderText="<%$ Resources:Resource,Unit %>">
                      <ItemTemplate>
                         <asp:Label ID="uiUnit" runat="server" />
                      </ItemTemplate>
                   </telerik:GridTemplateColumn>
                </Columns>
             </MasterTableView>
          </telerik:RadGrid>
       </ContentTemplate>
    </asp:UpdatePanel>

And here is the code behind :

    protected void uiImport_Click(object sender, EventArgs e)
        {
            // clear message
            uiErrorMsg.Text = "";
            uiSuccessMsg2.Text = "";

            StringBuilder message = new StringBuilder(1024);

            HttpResponseMessage result = null;

            if (uiUpload.UploadedFiles.Count > 0)
            {
                result = ImportData();

                if (result.IsSuccessStatusCode)
                {
                    message.Append(Convert.ToString(HttpContext.GetGlobalResourceObject("Resource", "Message_Import_Data_Successful")));
                    message.Append(Environment.NewLine);
                    try
                    {
                        _usageData.Dispose();
                        _usageData = null;
                    }
                    catch { }
                    
                    BindGrid(true); // refresh grid.

                    // update task modified by and date
                    bool hasError = false;
                    Common.Systems.Sustainability.Constants.ApprovalStatuses status = Common.Systems.Sustainability.Constants.ApprovalStatuses.Undefined;
                    bool isApprovedOrRejected = WorkflowUtil.IsApprovedOrRejected(_taskID.Value, ref status);
                    if (isApprovedOrRejected)
                    {
                        // re-cache data for dashboards
                        int companyID = Common.WebUtil.GetCompanyID();
                        Thread childThread = new Thread(() => Util.ReCacheForDashboards(Cache, companyID));
                        childThread.Start();
                    }
                    else
                    {
                        UpdateTask(ref hasError);
                    }
                }
                else
                {
                    string msg = Convert.ToString(HttpContext.GetGlobalResourceObject("Resource", "Message_Unable_To_Import_Data"));
                    message.Append(msg);
                    message.Append(Environment.NewLine);

                    string resultMessage = result.Content.ReadAsStringAsync().Result;
                    if (resultMessage.IndexOf("ExceptionMessage", StringComparison.OrdinalIgnoreCase) > -1)
                    {
                        resultMessage = resultMessage.Replace("\\r\\n", "<br />");
                        Logger.Log(string.Format("Error occurs in the '{0}.{1}' method.{2}{3}"
                            , System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString()
                            , System.Reflection.MethodBase.GetCurrentMethod().Name
                            , Environment.NewLine
                            , resultMessage));
                    }
                    else
                    {
                        message.Append(Common.Util.ReformatMessage(resultMessage));
                    }
                } // end if
            } // end if

            if (result != null)
            {
                if (result.IsSuccessStatusCode)
                {
                    uiSuccessMsg2.Text = message.Replace(Environment.NewLine, "<br />").ToString();
                }
                else
                {
                    // show error message on web.
                    //uiErrorMsg.Text = message.Replace(Environment.NewLine, "<br />").ToString();
                    //uiPanel2.Alert(message.ToString());
                    uiReportPanel.Alert(message.ToString());
                } // end if
            } // end if
        }


    private void BindGrid(bool performDataBind = true)
        {
            DataTable locationsTable = null;
            DataTable indicatorsTable = null;
            try
            {
                // try to get delegation, location and indicators information, it contains order of locations and indicators
                // order numbers will be for sorting in below
                try
                {
                    _delegation = GetDelegationByTaskID(_taskID.Value);
                    int delegationID = Convert.ToInt32(_delegation.Tables[0].Rows[0][Common.Systems.Sustainability.Constants.Delegation.ID]);
                    _delegationLocationsAndIndicators = GetDelegationLocationsAndIndicatorsByDelegationID(delegationID);
                }
                catch { }

                // remove all columns
                for (int i = 3; i < uiGrid.MasterTableView.Columns.Count; i++)
                {
                    GridColumn col = uiGrid.MasterTableView.Columns[i];
                    uiGrid.MasterTableView.Columns.Remove(col);
                    i--;
                }

                DataSet usage = GetUsageData();
                //using (DataSet usage = GetUsageData())
                //{
                
                {
                    locationsTable = usage.Tables[0].DefaultView.ToTable(true, new string[] {
                            Common.Systems.Sustainability.Constants.DelegationLocationAndIndicator.LocationID
                            , Common.Systems.Sustainability.Constants.Location.LocationName
                        }
                    );

                    // As requested by user in 2016-07, sorting location and indicator based on delegation selected ordering.
                    if (_delegationLocationsAndIndicators != null)
                    {
                        locationsTable.Columns.Add(Common.Systems.Sustainability.Constants.DelegationLocationAndIndicator.SequenceForLocation, Type.GetType("System.Int32"));
                        foreach (DataRow dr in locationsTable.Rows)
                        {
                            DataRow[] dli = _delegationLocationsAndIndicators.Tables[0].Select(string.Format("{0} = {1}"
                                        , Common.Systems.Sustainability.Constants.DelegationLocationAndIndicator.LocationID
                                        , dr[ .Common.Systems.Sustainability.Constants.DelegationLocationAndIndicator.LocationID]
                                    ));
                            if (dli.Length > 0)
                            {
                                int? sequence =  .Common.Util.TryToConvertToInt32(dli[0],  .Common.Systems.Sustainability.Constants.DelegationLocationAndIndicator.SequenceForLocation);
                                if (sequence != null)
                                {
                                    dr[ .Common.Systems.Sustainability.Constants.DelegationLocationAndIndicator.SequenceForLocation] = sequence.Value;
                                }
                            }
                        }

                        locationsTable.DefaultView.Sort =  .Common.Systems.Sustainability.Constants.DelegationLocationAndIndicator.SequenceForLocation;
                        DataTable temp = locationsTable.DefaultView.ToTable();
                        locationsTable.Dispose();
                        locationsTable = temp;
                    }


                    // append locations to grid view
                    int i = 0;
                    foreach (DataRow dr in locationsTable.Rows)
                    {
                        string locationID = Convert.ToString(dr["LocationID"]);
                        string locationName = Convert.ToString(dr["LocationName"]);

                        GridTemplateColumn tplColumn = new GridTemplateColumn();
                        tplColumn.ItemTemplate = new UsageColumnTemplate(locationName, i.ToString(), locationID, _currencies);
                        tplColumn.HeaderText = locationName;
                        uiGrid.MasterTableView.Columns.Add(tplColumn);

                        i++;
                    }

                    
                }


                // filter out indicators if no location associated
                {
                    indicatorsTable = usage.Tables[0].DefaultView.ToTable(true, new string[] {
                             .Common.Systems.Sustainability.Constants.DelegationLocationAndIndicator.IndicatorID
                            ,  .Common.Systems.Sustainability.Constants.Indicator.IndicatorName
                            , "IndicatorParentName" // Added by HC on 2016-06-08, as requested by users, use parent indicator name as group on the grid view.
                        }
                    );

                    // As requested by user in 2016-07, sorting location and indicator based on delegation selected ordering.
                    if (_delegationLocationsAndIndicators != null)
                    {
                        indicatorsTable.Columns.Add( .Common.Systems.Sustainability.Constants.DelegationLocationAndIndicator.SequenceForIndicator, Type.GetType("System.Int32"));
                        foreach (DataRow dr in indicatorsTable.Rows)
                        {
                            DataRow[] dli = _delegationLocationsAndIndicators.Tables[0].Select(string.Format("{0} = {1}"
                                        ,  .Common.Systems.Sustainability.Constants.DelegationLocationAndIndicator.IndicatorID
                                        , dr[ .Common.Systems.Sustainability.Constants.DelegationLocationAndIndicator.IndicatorID]
                                    ));
                            if (dli.Length > 0)
                            {
                                int? sequence =  .Common.Util.TryToConvertToInt32(dli[0],  .Common.Systems.Sustainability.Constants.DelegationLocationAndIndicator.SequenceForIndicator);
                                if (sequence != null)
                                {
                                    dr[ .Common.Systems.Sustainability.Constants.DelegationLocationAndIndicator.SequenceForIndicator] = sequence.Value;
                                }
                            }
                        }

                        indicatorsTable.DefaultView.Sort =  .Common.Systems.Sustainability.Constants.DelegationLocationAndIndicator.SequenceForIndicator;
                        DataTable temp = indicatorsTable.DefaultView.ToTable();
                        indicatorsTable.Dispose();
                        indicatorsTable = temp;
                    }

                    // bind indicators to grid view
                    uiGrid.DataSource = indicatorsTable;
                    //if (performDataBind)
                    //uiGrid.Rebind();
                }
                    
                //} // end using
            }
            finally
            {
                if (locationsTable != null)
                {
                    locationsTable.Dispose();
                    locationsTable = null;
                }
                if (indicatorsTable != null)
                {
                    indicatorsTable.Dispose();
                    indicatorsTable = null;
                }
            }
        }
Eyup
Telerik team
 answered on 14 Jan 2019
Narrow your results
Selected tags
Tags
+? more
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?