Telerik Forums
UI for ASP.NET AJAX Forum
4 answers
128 views
Hello, I have a grid (gridEdit) where I am trying to attach a client side handler to certain auto generated edit elements.  I seem to have a valid reference and no errors are being thrown, but the handler never gets called.

Code behind:
protected void gridEdit_ItemDataBound(object sender, GridItemEventArgs e)
{
    if (e.Item is GridEditableItem && e.Item.IsInEditMode)
    {
        GridEditableItem form = (GridEditableItem)e.Item;
        for (int i = 0; i < _charFieldLength.Count; i++)
        {
            TextBox dataField = (TextBox)form[_charFieldLength[i].FieldName].Controls[0];
            dataField.MaxLength = _charFieldLength[i].DataLength;
        }
        for (int j = 0; j < form.Controls.Count; j++)
        {
            try
            {
                if (form.Controls[j].Controls[0] is RadNumericTextBox)
                {
                    RadNumericTextBox rnt = (RadNumericTextBox)form.Controls[j].Controls[0];
                    rnt.ClientEvents.OnKeyPress = "NumericOnKeyPress";
                }
            }
            catch (Exception ex) { }
        }
    }
}


Javascript:
function NumericOnKeyPress( sender, args )
{
    alert( 'In KeyPressHandler' );
}
Marbry
Top achievements
Rank 1
 answered on 27 Dec 2011
7 answers
544 views

A question on RabTabStrip, RadMultiPage, FormViews, two-way databinding, and dynamically loaded user controls:

Has anyone put them all together sucessfully!?

The closest Telerik demos I can find (such as TabStrip / Dynamic RadPageView) do the dynamic loading of user controls but they lack a formview and data binding features.

I've almost got there.  At present I have managed to put together a FormView which includes several RadPageViews.  I have placed a user control inside each RadPageView declaratively.  This works great but when I try to add a RadPageView dynamically (inside Page_Load) and load the user control dynamically (PageViewCreated event) my data is no longer bound to the controls inside the loaded user control (no error).

My FormView ID is FormView1 in the example below.  FormView1 is binding before before the PageView which I expect is the problem.
 
How can I add the PageView before the FormView begins binding (assuming this is the problem)?

        protected void Page_Load(object sender, EventArgs e)  
        {  
            if (!IsPostBack)  
            {  
                RadTab tab = new RadTab();  
                tab.Text = "Tab1";  
                TabStrip.Tabs.Add(tab);  
                RadPageView pageView = new RadPageView();  
                pageView.ID = "PageView1";  
                //next line is triggering data binding which is perhaps too early? PageView has not been added yet  
                RadMultiPage MultiPage1 = (RadMultiPage)FormView1.FindControl("MultiPage1");  
                MultiPage1.PageViews.Add(pageView);  
            }  
        }  
 
        protected void RadMultiPage1_PageViewCreated(object sender, RadMultiPageEventArgs e)  
        {  
            string userControlName = e.PageView.ID + ".ascx";  
            Control userControl = Page.LoadControl(userControlName);  
            userControl.ID = e.PageView.ID + "Control";  
            e.PageView.Controls.Add(userControl);  
        }   
 

More generally, in this scenario where I am trying to have one page, one formview, and one tabset with a different .ascx user control in each tab, is it advisable to instead use a different formview inside each control?  (These .ascx user controls are never re-used.)

Thanks!
John
Top achievements
Rank 1
 answered on 27 Dec 2011
4 answers
197 views
Hi. I am working on a project that will use the RadFileExplorer to show directories for specific security levels.

I know that there is a way to hardcode the items (see below code) which will be visible however, since I need to show directories and hide directories depending on the user's security level, I need it to work dynamically. I would like to pass in a list of security levels and use a switch statement to hide/show the appropriate directories depending on the user's security level.

            public override DirectoryItem ResolveRootDirectoryAsTree(string path)
                {
                DirectoryItem originalFolder = base.ResolveRootDirectoryAsTree(path);
                DirectoryItem[] originalDirectories = originalFolder.Directories;
                List<DirectoryItem> filteredDirectories = new List<DirectoryItem>();

                // Filter the folders
                foreach (DirectoryItem originalDir in originalDirectories)
                    {
                    if (!this.IsFiltered(originalDir.Name))
                        {
                        filteredDirectories.Add(originalDir);
                        }
                    }
                DirectoryItem newFolder = new DirectoryItem(originalFolder.Name, originalFolder.Location, originalFolder.FullPath, originalFolder.Tag, originalFolder.Permissions, originalFolder.Files, filteredDirectories.ToArray());

                return newFolder;
                }

            private bool IsFiltered(string name)
                {
               //I NEED THIS AREA TO BE DYNAMIC
            


                if (name.ToLower().EndsWith(".sys") ||
                    name.ToLower().Contains("_sys") ||
                    name == "Secure Directory1" ||
                    name == "Secure Directory2")
                    {
                    return true;
                    }

                // else
                return false;
                }

Thanks,
James
Osama
Top achievements
Rank 2
 answered on 27 Dec 2011
5 answers
245 views
I am trying to change the color of the header row when its in expanded mode. I tried the below code but didn't work.

Protected Sub RadGrid1_ItemDataBound(ByVal sender As Object, ByVal e As GridItemEventArgs) Handles RadGrid1.ItemDataBound
        If TypeOf e.Item Is GridGroupHeaderItem Then
            Dim gpheader As GridGroupHeaderItem = CType(e.Item, GridGroupHeaderItem)
 
           If item.Selected Then
             gpheader.BackColor = Drawing.Color.DarkSeaGreen
            End If
End Sub

Any other way?
Vijaianand
Top achievements
Rank 1
 answered on 27 Dec 2011
6 answers
190 views
I am trying to alter the visibility of a RadAjaxPanel that is within an ASP FormView. Please suggest an approach that works; the following approach does not:

FormView 

fv = form1.FindControl("FormView1") as FormView;

RadAjaxPanel myPanel = fv.FindControl("ThePanelOfInterest") as RadAjaxPanel;

myPanel.Visible = true;

myPanel is always shown as null even though it does exist.

Sy
Top achievements
Rank 1
 answered on 27 Dec 2011
13 answers
646 views
Hi!

I have a fileexplorer in an usercontrol. When i select an order on my normal page, it will set a property in the usercontrol. Based on that property, the initialpath, updatepaths, viewpaths and deletepaths should be changed. But somehow i can't get this to work. I can't do this in the page_Load event or FileExplorer_Load event because the property won't be set at this time. What is the right time to do this and how should i do this?

Regards,
Marlou
Karl Wilkens
Top achievements
Rank 1
 answered on 27 Dec 2011
3 answers
173 views
I have two different grids on two different pages (one grid per page).
Both grids have been populated with data containing a single row.
Both grids have a GridButtonColumn for requesting processing against the data row.
Both grids are defined nearly exactly (except for data column names, etc.)
Both grids have a "_ItemCommand" in the code behind file for processing the buttons/data.
Both grids contain exactly the same code in the code behind file (except for the column name they are handling/examining).

The first grid functions perfectly and the button performs as advertised.

The second grid will not process correctly.  It blows up with a "" error.  It does see the button event. It does trigger the intended event code.

The code behind event code is:

protected void QualContsGrid_ItemCommand(Object source, Telerik.Web.UI.GridCommandEventArgs e)
{
    if (e.CommandName == "RemoveContribution")
    {
        //  First we need to get the key value of the record the user wants to remove from the list
        string code = (string)e.CommandArgument;
        string id = (e.Item as GridDataItem).GetDataKeyValue("VoterQualifyingContributionId").ToString();
        Int32 iContributorRecKey = Convert.ToInt32(id);
 
        //  Now we can get the record, change it (remove it from the list), and update it
        ElectronicPetitionSystemDataContext efdc = new ElectronicPetitionSystemDataContext(ConfigurationManager.ConnectionStrings["ElectronicPetitionSystemConnectionString"].ConnectionString);
        VoterQualifyingContribution qc = efdc.VoterQualifyingContributions.Single(qcrec => qcrec.VoterQualifyingContributionId == iContributorRecKey);
        string sFirst = qc.FirstName;
        string sLast = qc.LastName;
        qc.VoterQualifyingContributionStatusId = 2;
        efdc.SubmitChanges();
        this.QualContsGrid.Rebind();
    }
}

The grid definition code is:

<telerik:RadGrid AutoGenerateColumns="false" ID="QualContsGrid" runat="server" Width="765px" OnItemCommand="QualContsGrid_ItemCommand"
    Height="430px"
    AllowSorting="true" AllowFilteringByColumn="true" EnableLinqExpressions="true"
    OnItemDataBound="QualContsGrid_ItemDataBound"
    AllowPaging="true" PageSize="15"
    BorderWidth="1px" BorderColor="#999999" EnableEmbeddedSkins="true" Skin="Default"
    DataSourceID="SQLDataSource1"
    ShowFooter="True" GridLines="None" >
    <StatusBarSettings ReadyText="Ready" LoadingText="Loading..." />
    <MasterTableView >
        <Columns>
            <telerik:GridBoundColumn HeaderStyle-Width="100px" UniqueName="VoterFirstName" HeaderText="First Name" DataField="FirstName" SortExpression="FirstName" >
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn HeaderStyle-Width="100px" UniqueName="VoterLastName" HeaderText="Last Name" DataField="LastName" SortExpression="LastName" >
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn HeaderStyle-Width="300px" UniqueName="VoterAddress" HeaderText="Address" DataField="Address" SortExpression="Address" >
            </telerik:GridBoundColumn >
            <telerik:GridButtonColumn DataTextFormatString="Remove" ButtonType="PushButton" UniqueName="RemoveContribution" HeaderStyle-Width="75px"
                ConfirmText="Are you certain that you want to remove this contribution?"  Text="Remove"
                HeaderText="Remove" CommandName="RemoveContribution" CommandArgument="VoterQualifyingContributionId" DataTextField="VoterQualifyingContributionId" >
            </telerik:GridButtonColumn>
            <telerik:GridBoundColumn HeaderStyle-Width="100px" UniqueName="ContributionStatus" HeaderText="Status" DataField="PaymentDescription" SortExpression="PaymentDescription" >
            </telerik:GridBoundColumn >
            <telerik:GridBoundColumn UniqueName="VoterQualifyingContributionId" HeaderText="" DataField="VoterQualifyingContributionId" Visible="false" >
            </telerik:GridBoundColumn >
        </Columns>
    </MasterTableView>
    <ClientSettings>
        <Scrolling AllowScroll="true" UseStaticHeaders="true" />
    </ClientSettings>
</telerik:RadGrid>

I have also attached two screen captures.

Many thanks in advance for any assistance you can give me!

Lynn



Jayesh Goyani
Top achievements
Rank 2
 answered on 27 Dec 2011
1 answer
169 views
Hi,
I have RadGrid with template field.In this i have textboxes.The user will enter values in textbox.The radgrid has paging option.How can i retain values in the previous page when user navigate to nextpage.How can i handle this ?
 
Richard
Top achievements
Rank 1
 answered on 27 Dec 2011
5 answers
519 views
I am trying to do two way databinding with a RadComboBox when Checkboxes="true". Getting them to save to the database is fine but binding each checked item when reading from the database isnt working. The CheckedItems property is read only so that wont work. I tried this next:

Dim branchBox As RadComboBox = FormView1.FindControl("branchBox")
For Each b As Branch In current.branches
    For Each item As RadComboBoxItem In branchBox.Items
        item.Checked = (b.branchId = item.Value)
    Next
Next

'current' is an instance of an Person entity in my Entity Framework. A Person has a collection of branches. I want to bind the RadComboBox to all of the branches for the person.

Doing the above, only the last item in the RadComboBox will be checked. So, if the person has "Army" and "Navy" as branches and Army appears before Navy in the RCB, only Navy will be checked. Army will be unchecked.

Is there a way to set multiple checkboxes in a RadComboBox in C#?
Kalina
Telerik team
 answered on 27 Dec 2011
1 answer
102 views
I am using the GridButton Column successfully to allow the user to trigger various processing events.  The "ConfirmText" (and associated) property(s) work great and provide a much needed assist.

However, are there any plans to add an additional messaging capability (actually 3) called something like:

(1) SuccessText;
(2) CancelText; and,
(3) ErrorText.

These 2 properties would provide the text for displaying confirmations to the user AFTER the event code has run. I'm not certain how you would trigger these displays, but for a quick run-through:

(a) The user clicks a button to delete a certain row (a more complex delete process than supported by the grid);
(b) The current "ConfirmText" then asks the user if this is what they want to do.
(c) If the user says "No", then the "CancelText" message would be displayed (i.e. - "the delete has been cancelled").
(d) If the user sanys "Yes", then following the execution of the event code, the "SuccessText" would be similarly displayed (i.e. - The delete was successful").
(e) Obviously, the "ErrorText" would be displayed if the event code triggered an error event.

As I said, I'm not certain how one could "trigger" the "SuccessText" or the "ErrorText", but if you could solve that, these capabilities would be very nice "user touch" enhancements.

Thanks for great products!

Lynn
Richard
Top achievements
Rank 1
 answered on 27 Dec 2011
Narrow your results
Selected tags
Tags
+? more
Top users last month
Simon
Top achievements
Rank 2
Iron
Iron
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Simon
Top achievements
Rank 2
Iron
Iron
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?