Telerik Forums
UI for ASP.NET AJAX Forum
14 answers
948 views

I have a combination of RadDropDownLists and RadComboBox's on a page, the last RadComboBox is losing it's selection(s) on PostBack. All other RadDropDownLists and RadComboBox's keep their selections on PostBack. What do I need to do to ensure the selections are not lost. I have tried enabling ViewState and several other suggestions found online, but none resolve the issue. Please advise.

ASPX:

<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="CobraStatusTemplate1.aspx.cs" Inherits="CobraStatus.aspx.CobraStatusTemplate1" %>
 
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
 
 
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
    <br />
    <telerik:RadDropDownList ID="rdlProject" runat="server" DefaultMessage="Select Project"
        OnSelectedIndexChanged="rdlProject_SelectedIndexChanged" AutoPostBack="true" Skin="Office2010Black" Enabled="true">
    </telerik:RadDropDownList>
 
    <telerik:RadDropDownList ID="rdlAnalyst" runat="server" DefaultMessage="Select Analyst"
        OnSelectedIndexChanged="rdlAnalyst_SelectedIndexChanged" AutoPostBack="true" Skin="Office2010Black" Enabled="false">
    </telerik:RadDropDownList>
 
    <telerik:RadComboBox ID="rcbControlAccount" runat="server" Text="Select Control Account" CheckBoxes="true"
        EnableCheckAllItemsCheckBox="true" OnSelectedIndexChanged="rcbControlAccount_SelectedIndexChanged" AutoPostBack="true" Skin="Office2010Black"
        Enabled="false">
    </telerik:RadComboBox>
 
    <telerik:RadComboBox ID="rcbEVT" runat="server" CheckBoxes="true" EnableCheckAllItemsCheckBox="true" AutoPostBack="true" Skin="Office2010Black"
        Enabled="false" OnSelectedIndexChanged="rcbEVT_SelectedIndexChanged">
    </telerik:RadComboBox>
 
    <br />
    <br />
 
    <telerik:RadGrid ID="RadGrid1" runat="server" OnNeedDataSource="RadGrid1_NeedDataSource" GroupPanelPosition="Top" OnItemDataBound="RadGrid1_ItemDataBound"
        OnPreRender="RadGrid1_PreRender" OnBatchEditCommand="RadGrid1_BatchEditCommand" Width="100%" Skin="Office2010Black">
        <MasterTableView AutoGenerateColumns="False" EditMode="Batch" CommandItemDisplay="Top" Width="100%">
            <CommandItemSettings ShowAddNewRecordButton="False" ShowSaveChangesButton="True" ShowCancelChangesButton="True"></CommandItemSettings>
            <Columns>
                <telerik:GridBoundColumn DataField="Project" HeaderText="Project" SortExpression="Project" UniqueName="Project"
                    FilterControlAltText="Filter Project column" ReadOnly="true">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Ca1" HeaderText="Control Account" SortExpression="Ca1" UniqueName="Ca1"
                    FilterControlAltText="Filter Ca1 column" ReadOnly="true">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Wp" HeaderText="Work Package" SortExpression="Wp" UniqueName="Wp" FilterControlAltText="Filter Wp column"
                    ReadOnly="true">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Descrip" HeaderText="Description" SortExpression="Descrip" UniqueName="Descrip"
                    FilterControlAltText="Filter Descrip column" ReadOnly="true">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Description" HeaderText="EV Technique" SortExpression="Pmt" UniqueName="Pmt"
                    FilterControlAltText="Filter Pmt column" ReadOnly="true">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="FullName" HeaderText="Analyst" SortExpression="C5" UniqueName="C5" FilterControlAltText="Filter C5 column"
                    ReadOnly="true">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="PcComp" HeaderText="% Complete" SortExpression="PcComp" UniqueName="PcComp" DataType="System.Decimal"
                    FilterControlAltText="Filter PcComp column" ReadOnly="true">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Ssd" HeaderText="Baseline Start Date" SortExpression="Ssd" UniqueName="Ssd" DataType="System.DateTime"
                    FilterControlAltText="Filter Ssd column" DataFormatString="{0:MM/dd/yyyy}" ReadOnly="true">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Sfd" HeaderText="Baseline Finish Date" SortExpression="Sfd" UniqueName="Sfd" DataType="System.DateTime"
                    FilterControlAltText="Filter Sfd column" DataFormatString="{0:MM/dd/yyyy}" ReadOnly="true">
                </telerik:GridBoundColumn>
                <telerik:GridDateTimeColumn DataField="Asd" HeaderText="Actual Start Date" SortExpression="Asd" UniqueName="Asd" DataType="System.DateTime"
                    FilterControlAltText="Filter Asd column" DataFormatString="{0:MM/dd/yyyy}" ReadOnly="false" HeaderStyle-Width="165px" HeaderStyle-ForeColor="#0000cc">
                </telerik:GridDateTimeColumn>
                <telerik:GridBoundColumn DataField="Afd" HeaderText="Actual Finish Date" SortExpression="Afd" UniqueName="Afd" DataType="System.DateTime"
                    FilterControlAltText="Filter Afd column" DataFormatString="{0:MM/dd/yyyy}" ReadOnly="true">
                </telerik:GridBoundColumn>              
                <telerik:GridBoundColumn DataField="UpdPcComp" HeaderText="Updated % Comp" SortExpression="UpdPcComp" UniqueName="UpdPcComp" DataType="System.Decimal"
                    FilterControlAltText="Filter UpdPcComp column" ReadOnly="false" HeaderStyle-ForeColor="#0000cc">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="UpdBy" HeaderText="Updated By" SortExpression="UpdBy" UniqueName="UpdBy"
                    FilterControlAltText="Filter UpdBy column" ReadOnly="true">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="UpdDate" HeaderText="Last Updated" SortExpression="UpdDate" UniqueName="UpdDate" DataType="System.DateTime"
                    FilterControlAltText="Filter UpdDate column" DataFormatString="{0:MM/dd/yyyy}" ReadOnly="true">
                </telerik:GridBoundColumn>
            </Columns>
        </MasterTableView>
    </telerik:RadGrid>
 
</asp:Content>

C#: 

using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Telerik.Web.UI;
 
namespace CobraStatus.aspx
{
    public partial class CobraStatusTemplate1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            projects();         
        }
        
        private void projects()
        {
            DataTable dt = new DataTable();
 
            using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["FinanceSystemsApplicationsConnectionString"].ConnectionString))
            {
                con.Open();
 
                SqlCommand cmd = new SqlCommand("SELECT ProgramId FROM csProgram ORDER BY ProgramId", con);
                SqlDataAdapter adapter = new SqlDataAdapter(cmd);
                adapter.Fill(dt);
            }
            rdlProject.DataSource = dt;
            rdlProject.DataTextField = "ProgramId";
            rdlProject.DataValueField = "ProgramId";
            rdlProject.DataBind();
        }
 
        private void analysts()
        {
            string project = rdlProject.SelectedValue;
 
            DataTable dt = new DataTable();
 
            using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["FinanceSystemsApplicationsConnectionString"].ConnectionString))
            {
                con.Open();
 
                SqlCommand cmd = new SqlCommand("SELECT DISTINCT csCawp.C5, csAnalysts.EmployeeId, csAnalysts.FullName FROM csCawp INNER JOIN " +
                         "csAnalysts ON csCawp.C5 = csAnalysts.EmployeeId WHERE Project = '" + project + "'", con);
                SqlDataAdapter adapter = new SqlDataAdapter(cmd);
                adapter.Fill(dt);
            }
            rdlAnalyst.DataSource = dt;
            rdlAnalyst.DataTextField = "FullName";
            rdlAnalyst.DataValueField = "EmployeeId";
            rdlAnalyst.DataBind();
 
        }
 
        private void controlAccount()
        {
            string project = rdlProject.SelectedValue;
            string analyst = rdlAnalyst.SelectedValue;
 
            DataTable dt = new DataTable();
 
            using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["FinanceSystemsApplicationsConnectionString"].ConnectionString))
            {
                con.Open();
 
                SqlCommand cmd = new SqlCommand("SELECT DISTINCT Ca1 FROM CsCAWP WHERE Project = '" + project + "' AND C5 = " + analyst + "", con);
                SqlDataAdapter adapter = new SqlDataAdapter(cmd);
                adapter.Fill(dt);
            }
            rcbControlAccount.DataSource = dt;
            rcbControlAccount.DataTextField = "Ca1";
            rcbControlAccount.DataValueField = "Ca1";
            rcbControlAccount.DataBind();         
        }
 
        private void evt()
        {
            string project = rdlProject.SelectedValue;
            string analyst = rdlAnalyst.SelectedValue;          
 
            DataTable dt = new DataTable();
 
            using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["FinanceSystemsApplicationsConnectionString"].ConnectionString))
            {
                string controlAccount = string.Empty;
                for (int i = 0; i < rcbControlAccount.CheckedItems.Count; i++)
                {
                    if (i < rcbControlAccount.CheckedItems.Count - 1)
                    {
                        controlAccount += rcbControlAccount.CheckedItems[i].Value;
                        controlAccount += "'";
                        controlAccount += ",";
                        controlAccount += "'";
                    }
                    else
                    {
                        controlAccount += rcbControlAccount.CheckedItems[i].Value;
                    }
                }
 
                conn.Open();
                
                SqlCommand cmnd = new SqlCommand("SELECT DISTINCT csEVT.Code, csEVT.Description FROM csCawp INNER JOIN csEVT ON csCawp.Pmt = csEVT.Code " +
                    "WHERE csCawp.Project = '" + project + "' AND csCawp.C5 = '" + analyst + "' AND csCawp.Ca1 IN ('" + controlAccount + "')", conn);
                SqlDataAdapter adp = new SqlDataAdapter(cmnd);
                adp.Fill(dt);
            }
            rcbEVT.DataSource = dt;
            rcbEVT.DataTextField = "Description";
            rcbEVT.DataValueField = "Code";
            rcbEVT.DataBind();        
        }
 
 
        protected void rdlProject_SelectedIndexChanged(object sender, Telerik.Web.UI.DropDownListEventArgs e)
        {
            analysts();
            rdlAnalyst.Enabled = true;
        }
 
        protected void rdlAnalyst_SelectedIndexChanged(object sender, Telerik.Web.UI.DropDownListEventArgs e)
        {
            controlAccount();
            rcbControlAccount.Enabled = true;         
        }
 
        protected void rcbControlAccount_SelectedIndexChanged(object sender, Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs e)
        {     
            evt();
            rcbEVT.Enabled = true;
        }
 
        protected void rcbEVT_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
        {
            RadGrid1.Rebind();
        }
 
        public DataTable GetDataTable(string query)
        {
 
            String ConnString = ConfigurationManager.ConnectionStrings["FinanceSystemsApplicationsConnectionString"].ConnectionString;
 
            SqlConnection conn = new SqlConnection(ConnString);
 
            SqlDataAdapter adapter = new SqlDataAdapter();
 
            adapter.SelectCommand = new SqlCommand(query, conn);
 
            DataTable myDataTable = new DataTable();
 
            conn.Open();
 
            try
            {
 
                adapter.Fill(myDataTable);
 
            }
 
            finally
            {
 
                conn.Close();
 
            }
 
            return myDataTable;
 
        }
 
        protected void RadGrid1_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
        {
 
            int rcbCA = rcbControlAccount.CheckedItems.Count;
            int rcbEvt = rcbEVT.CheckedItems.Count;
            if (rdlProject.SelectedValue != "" && rdlAnalyst.SelectedValue != "" && rcbCA > 0 && rcbEvt > 0)          
            {             
                string project = rdlProject.SelectedValue;
                string analyst = rdlAnalyst.SelectedValue;
                string controlAccount = string.Empty;
                for (int i = 0; i < rcbControlAccount.CheckedItems.Count; i++)
                {
                    if (i < rcbControlAccount.CheckedItems.Count - 1)
                    {
                        controlAccount += rcbControlAccount.CheckedItems[i].Value;
                        controlAccount += "'";
                        controlAccount += ",";
                        controlAccount += "'";
                    }
                    else
                    {
                        controlAccount += rcbControlAccount.CheckedItems[i].Value;
                    }
                }
 
                string evt = string.Empty;
                for (int i = 0; i < rcbEVT.CheckedItems.Count; i++)
                {
                    if (i < rcbEVT.CheckedItems.Count - 1)
                    {
                        evt += rcbEVT.CheckedItems[i].Value;
                        evt += "'";
                        evt += ",";
                        evt += "'";
                    }
                    else
                    {
                        evt += rcbEVT.CheckedItems[i].Value;
                    }
                }
               
                RadGrid1.DataSource = GetDataTable("SELECT csCawp.Project, csCawp.Ca1, csCawp.Wp, csCawp.Descrip, csEVT.Description, csAnalysts.FullName, csCawp.PcComp," +
                    "csCawp.Ssd, csCawp.Sfd, csCawp.Asd, csCawp.Afd, csCawp.UpdPcComp, csCawp.UpdDate, csCawp.UpdBy FROM csCawp INNER JOIN csEVT ON csCawp.Pmt = csEVT.Code INNER JOIN " +
                    "csAnalysts ON CsCawp.C5 = csAnalysts.EmployeeId  " +
                   " WHERE PROJECT = '" + project + "' AND Ca1 IN ('" + controlAccount + "') AND Pmt IN ('" + evt + "')");              
            }
        }
 
        protected void Button1_Click(object sender, EventArgs e)
        {
 
        }
 
        protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
        {
            if (e.Item is GridDataItem)
            {
                GridDataItem item = (GridDataItem)e.Item;
                if (item["PcComp"].Text == "0.000000")
                    item.ForeColor = Color.Red;
            }
        }
 
        protected void RadGrid1_PreRender(object sender, EventArgs e)
        {
            
        }
 
        protected void RadGrid1_BatchEditCommand(object sender, GridBatchEditingEventArgs e)
        {
 
        }
        
 
    }
}

 

Thanks in advance,

Josh 

 

Ivan Danchev
Telerik team
 answered on 29 Apr 2015
7 answers
236 views
Hi
Is there a possibility to use a ControlParameter as SelectParameter in RadClientDataSource similar to ObjectDataSource?
Maria Ilieva
Telerik team
 answered on 29 Apr 2015
5 answers
349 views
Hi

I have created a method that serverside clears all filters,

foreach (GridColumn column in radGrid.MasterTableView.Columns)
            {
                 
                column.CurrentFilterFunction = GridKnownFunction.NoFilter;
                column.CurrentFilterValue = string.Empty;
            }
            radGrid.MasterTableView.FilterExpression = string.Empty;
            radGrid.MasterTableView.Rebind();

Works as expected,  but the checkboxes in the Checklists are not unchecked.
Can I somehow uncheck the Checklists serverside?
(The grid filertype is "Combined") 

 

Regards
John

Konstantin Dikov
Telerik team
 answered on 29 Apr 2015
2 answers
80 views

Hi,

I am using the radcombobox on web pages throughout my application.  If I select an item, then highlight the selected text and press the delete button, the text comes back when I click away.

When I submit the page, it results in the radcombobox having a text value, but the selectedindex is -1 and there is no selectedvalue.

If anyone has experienced this issue and has any advice it would be very appreciated.

Thanks.

Aneliya Petkova
Telerik team
 answered on 29 Apr 2015
1 answer
97 views

Hi,

I'm sure that answer already exists, but I searched through the forum and couldn't find a solution. 

I have a batch mode grid that invokes a web service, during the OnBatchEditCommand event, when saving data.  The service performs the update and returns a DataTable which identifies the results of the insert/update/delete actions.  The results include a status, error message and datetime value for every row that was processed. 

To help the user, we have a GridTemplateColumn (seen below), containing an image used to depict the results.  If the status is "Ok", we want to display a green check mark.  If the status is "Error", we want to display a red 'X'.  As you can imagine, in order for the user to correct the error, we don't want to overwrite any data that they may have entered.  As such, we don't want to reset the grids DataSource.  (Note that we do validate the data prior to calling the web service, but need to be cautious.)

<telerik:GridTemplateColumn ItemStyle-Wrap="false" DataField="STATUS" FilterControlAltText="Filter STATUS column" HeaderText="Row Status" SortExpression="STATUS" UniqueName="STATUS">
<ItemTemplate>
<asp:Image runat="server" ID="RowStatus" ImageUrl='<%#"/_layouts/15/images/projname/MUE_" + Eval("STATUS") + ".png"%>' />
</ItemTemplate>
</telerik:GridTemplateColumn>

So, after obtaining the returned DataTable, we would like to loop through the grid's rows, setting the value of the GridTemplateColumn to the value provided in the DataTable (either "Ok" or "Error").  Doing so, will allow us to display the MUE_Ok.png or MUE_Error.png image.  Obviously, we're open to other solutions that meet our user's requirements.  Note that the initial call to retrieve data, performed during the NeedDataSource event, returns a DataTable that currently includes an "Ok" value (along with all of the other data values) for each row.  As such, each row initially shows the green check mark. 

 Thanks.

Konstantin Dikov
Telerik team
 answered on 29 Apr 2015
2 answers
173 views

Hello,

I'm working on a project that contains a RadTreeView.

When the user clicks on a node, it fires the JS event “OnClientClicking”.

 

Sometimes we need to set args.set_cancel(true), in order to prevent going to server side.

Therefore, the node that was clicked is not selected, nor is it highlighted.

How can I prevent the event from accessing the server side – yet select the node and highlight it?

Thanks,
Daniel.

Daniel
Top achievements
Rank 1
 answered on 29 Apr 2015
2 answers
180 views

Hello,

I'm working on a project that should contain a RadNumericTextBox.

The project requirements are that when the user clicks a button, a RadNumericTextBox will be created dynamically on the client side.

The RadNumericTextBox will contain a SpinButton and also validation of MinValue, MaxValue.

 

How to do this in Client-Side using JS?

Thanks,
Daniel

Daniel
Top achievements
Rank 1
 answered on 29 Apr 2015
1 answer
68 views

Good Morning,

I am new to the forum and I apologize for my English. I'm Italian.

I have developed a grid with 6 levels. I have this problem.

I want that the next detailTable, is expanded only if he are the row. if it is empty should not be possible to expand.
I do not want  this only on the first detailtable, but to the all.
How is possilble?

I've check the function "HideExpandColumnRecursive" but not work for me!

Any idea?

Thanks for your support.

 

Kostadin
Telerik team
 answered on 29 Apr 2015
5 answers
456 views
I'm looking to perform an additional calculation on the auto-calculated grand total columns.  The first column is a 'Total Revenue' column and the second is a 'Total Duration' column.  I'd like to divide 'Total Revenue' by 'Total Duration' and write this value to a new column.

How would I achieve this?
Konstantin Dikov
Telerik team
 answered on 29 Apr 2015
1 answer
130 views

Hello,

 Does Telerik have any tools that allow you to display a powerpoint on a web page?

Using asp.net

Marin Bratanov
Telerik team
 answered on 29 Apr 2015
Narrow your results
Selected tags
Tags
+? more
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?