Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
384 views
Hi all,

I am using a webusercontrol for my insert / edit of my radgrid. The insert seems to work fine, except the window doesn't close. After the save, if I click the close X then everything is fine - but it should do that automatically. The other problem is that my edit doesn't work - doesn't pull information in. I'm sure that's because I'm not doing anything to bind it.

So - first question - my .ascx file is using a FormView control and does all of the binding like a normal page would. Is that correct? I really couldn't find a simple example of how to do this.

If 'yes' and I have done that part right - then how do I get my edit to tie to my grid?

Thanks so much. I've included code here:

1. Grid:
<telerik:RadGrid runat="server" ID="gvPatientSearch" DataSourceID="dsPatients" AllowAutomaticInserts="true">
    <ClientSettings>  
        <ClientEvents OnPopUpShowing="PopUpShowing" /> 
    </ClientSettings
    <MasterTableView DataKeyNames="patientID" CommandItemDisplay="Top" Width="100%" EditMode="PopUp">
        <EditFormSettings 
            UserControlName="~/App_Assets/Controls/patientControl.ascx"
            EditFormType="WebUserControl"  
            CaptionDataField="lastName" 
            CaptionFormatString="Edit Patient Record for {0}"
            InsertCaption="New Patient"
            FormStyle-Width="600px"
            
        </EditFormSettings>
        <CommandItemSettings ShowAddNewRecordButton="true" AddNewRecordText="Add New Patient" />
        <Columns>
            ...
            <telerik:GridEditCommandColumn />
        </Columns>
    </MasterTableView>    
</telerik:RadGrid>

2. My user control looks like this:

<%@ Control Language="VB" AutoEventWireup="false" CodeFile="patientControl.ascx.vb" Inherits="App_Assets_Controls_patientControl" %>
    <div align="center">
        <asp:FormView runat="server" ID="fvPatients" DataKeyNames="patientID" DataSourceID="dsPatients" DefaultMode="Insert">
            <EditItemTemplate>
                <table class="searchTable" style="border: 1px solid #2a5690; background-color: #f7f5f0;" cellpadding="3" cellspacing="1" width="99%">
                <tr>
                    <td align="right">Last Name:</td>
                    <td>
                        <telerik:RadTextBox runat="server" ID="txtLastName" Text='<%# Bind("lastName") %>' MaxLength="50" />
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="txtLastName" CssClass="errorMessage">«</asp:RequiredFieldValidator>
                    </td>
                </tr>
                <tr>
                    <td align="right">First Name:</td>
                    <td>
                        <telerik:RadTextBox runat="server" ID="txtFirstName" Text='<%# Bind("firstName") %>' MaxLength="50" />
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="txtFirstName" CssClass="errorMessage">«</asp:RequiredFieldValidator>
                    </td>
                </tr>
                <tr>
                    <td align="right">Middle Name:</td>
                    <td>
                        <telerik:RadTextBox runat="server" ID="txtMiddleName" Text='<%# Bind("middleName") %>' MaxLength="50" />
                    </td>
                </tr>
                <tr>
                    <td align="right" valign="top">Sex:</td>
                    <td valign="top">
                        <asp:RadioButtonList runat="server" RepeatDirection="Horizontal" ID="cboSex" SelectedValue='<%# Bind("sex") %>'>
                            <asp:ListItem Text="Male" Value="M" />
                            <asp:ListItem Text="Female" Value="F" />
                        </asp:RadioButtonList>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="cboSex" CssClass="errorMessage">please choose sex</asp:RequiredFieldValidator>
                    </td>
                </tr>
                <tr>
                    <td align="right">Date of Birth:</td>
                    <td>
                        <telerik:RadDateInput MinDate="01/01/1900" runat="server" ID="dteDateOfBirth" SelectedDate='<%# Bind("dateOfBirth") %>' />
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ControlToValidate="dteDateOfBirth" CssClass="errorMessage">«</asp:RequiredFieldValidator>
                    </td>
                </tr>
                <tr>
                    <td align="right">SSN:</td>
                    <td>
                        <telerik:RadMaskedTextBox ID="txtSSN" runat="server" Mask="###-##-####" TextWithLiterals="-" Width="75px" Text='<%# Bind("ssn") %>' />
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" ControlToValidate="txtSSN" CssClass="errorMessage">«</asp:RequiredFieldValidator>
                    </td>
                </tr>
                <tr>
                    <td align="right">Phone Number:</td>
                    <td>
                        <telerik:RadMaskedTextBox runat="server" ID="txtPhoneNumber" Mask="###-###-####" TextWithLiterals="-" MaxLength="15" Text='<%# Bind("phoneNumber") %>' />
                    </td>
                </tr>
                <tr>
                    <td align="right">Alternate (Cell) Phone Number:</td>
                    <td><telerik:RadMaskedTextBox runat="server" ID="txtPhoneNumber2" Mask="###-###-####" TextWithLiterals="-" MaxLength="15" Text='<%# Bind("phoneNumber2") %>' /></td>
                </tr>
                <tr>
                    <td align="right">Address Line 1:</td>
                    <td><telerik:RadTextBox runat="server" ID="txtAddressLine1" MaxLength="150" Text='<%# Bind("addressLine1") %>' /></td>
                </tr>
                <tr>
                    <td align="right">Address Line 2:</td>
                    <td><telerik:RadTextBox runat="server" ID="txtAddressLine2" MaxLength="150" Text='<%# Bind("addressLine2") %>' /></td>
                </tr>
                <tr>
                    <td align="right">City:</td>
                    <td><telerik:RadTextBox runat="server" ID="txtCity" EmptyMessage="enter city" MaxLength="50" Text='<%# Bind("city") %>' /></td>
                </tr>
                <tr>
                    <td align="right">State:</td>
                    <td><telerik:RadTextBox runat="server" ID="txtState" EmptyMessage="enter state" MaxLength="2" Text='<%# Bind("state") %>' /></td>
                </tr>
                <tr>
                    <td align="right">Zip Code:</td>
                    <td><telerik:RadTextBox runat="server" ID="txtZipCode" EmptyMessage="enter zip code" MaxLength="10" Text='<%# Bind("zipCode") %>' /></td>
                </tr>
                <tr>
                    <td align="right">Email Address:</td>
                    <td><telerik:RadTextBox runat="server" ID="txtEmailAddress" Text='<%# Bind("emailAddress") %>' /></td>
                </tr>
                <tr>
                    <td align="right">Hospital Patient ID:</td>
                    <td><telerik:RadTextBox runat="server" ID="txtHospitalPatientID" Text='<%# Bind("hospitalPatientID") %>' /></td>
                </tr>
                <tr>
                    <td></td>
                    <td><telerik:RadButton CommandName="Insert" runat="server" ID="btnSave" Text="Add Patient" /></td>
                </tr>
                </table>
            </EditItemTemplate>
        </asp:FormView>
    </div>
  
    <asp:SqlDataSource runat="server" ID="dsPatients" 
        SelectCommandType="StoredProcedure" SelectCommand="sp_Patients"
        InsertCommandType="StoredProcedure" InsertCommand="sp_Patients"
        UpdateCommandType="StoredProcedure" UpdateCommand="sp_Patients"
        >
        <SelectParameters>
            <asp:Parameter Name="Action" DefaultValue="SELECT" />
            <asp:QueryStringParameter Name="patientID" QueryStringField="patientID" />
        </SelectParameters>
        <InsertParameters>
            <asp:Parameter Name="Action" DefaultValue="INSERT" />
            <asp:CookieParameter Name="lastUpdatedBy" CookieName="userName" />
        </InsertParameters>
        <UpdateParameters>
            <asp:Parameter Name="Action" DefaultValue="UPDATE" />
            <asp:CookieParameter Name="lastUpdatedBy" CookieName="userName" />
        </UpdateParameters>
    </asp:SqlDataSource>

Thanks for your help!
Marin
Telerik team
 answered on 01 Jul 2011
3 answers
73 views
I have put some additional logic into the ItemDataBound event to handle the conditional colour formatting which works perfectly on the initial screen display.  However when i click on one of my column headers to sort my data by the column the formatting is lost on the sorted column. 

Can anyone shed any light on why this is happening.

Here is my code from my ItemDataBound Event

protected void gridTxnEnquiry_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
{
    if (e.Item is GridDataItem)
    {           
        GridDataItem dataItem = (GridDataItem)e.Item;
         DataRow dr = ((DataRowView)e.Item.DataItem).Row;
 
        // Set the Back Colour depending on the Record Type
        int rectype = int.Parse(dr["RecordType"].ToString());
         switch (rectype)
        {
            case 0:
            dataItem.BackColor = Color.Blue
            break;           
            case 1:
            dataItem.BackColor = Color.Red
            break;
        }
    }
}

Stuart Ferguson
Top achievements
Rank 1
 answered on 01 Jul 2011
4 answers
141 views
I am guessing this has been talked about before and there is probably a very easy solution, but I can't seem to find it.

I have a form which a whole bunch of other radcontrols that do an autopostback, I am finding that if a user selects the icon to open the calendar on the RadDatePicker quickly after moving off another field that the dates are unselectable on the calendar.  It seems like it is opening in the middle of the postback or something and disables it.  The only way to get out of this state is to go to another field, make a change, and then back to the calendar. 

Has anyone seen this?  Is there a way to disable that icon while in the middle of postback or something along those lines?

Thanks so much
Andy
Top achievements
Rank 1
 answered on 01 Jul 2011
2 answers
114 views
Hi All,

Is there a way to get a title on a pane to include an image?  As per the attached.  The left part shows what it is now and the right is roughly how I'd like it to look.

Obviously not a critical requirement but enhances the appearance of the page.

Regards,

Jon
Jon
Top achievements
Rank 1
 answered on 01 Jul 2011
1 answer
160 views
Hi,

We are using the the Editor and an UpdatePanel. In this combination when running in IE9-mode, there is probably a memory leak.

Example:
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="editormem.aspx.vb" Inherits="WebApplication4.editormem" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <telerik:RadScriptManager ID="ccc" runat="server">
    </telerik:RadScriptManager>
    <div>
        <asp:UpdatePanel ID="up" runat="server" ChildrenAsTriggers="true" UpdateMode="Conditional">
            <ContentTemplate>
                <asp:Button ID="aa" runat="server" Text="Hit me multiple times" />
                <telerik:RadEditor ID="re" runat="server" ContentAreaMode="Div">
                    <Content>
                        Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test<br />Test
                    </Content>
                </telerik:RadEditor>
            </ContentTemplate>
        </asp:UpdatePanel>
    </div>
    </form>
</body>
</html>

Each click on the button generates almost 1M more memory in the task manager which wont go away until a reload of the page!!!

Regards
Caesar
Georgi Tunev
Telerik team
 answered on 01 Jul 2011
3 answers
118 views
I have the following code intended take values selected in a RadGrid and use them as parameters in a SQL insert query.  Unfortunately this is not working and I suspect the problem is that I am not pulling the cell values for the selected rows properly.  Note, AmtDue is a calculated column value.

Can tell me where I went wrong? 

protected void RadButton2_Click(object sender, EventArgs e)
{
    foreach (GridDataItem item in RadGrid1.SelectedItems)
    {
        //GridDataItem item = (GridDataItem)RadGrid1.SelectedItems;
        int UserID = Convert.ToInt16(item["UserID"].ToString());
        string Type = "D";
        DateTime Date = DateTime.Now;
        string Description = "Monthly Storage Fee - Tag: " + (item["PackageTag"].ToString()) + Label3.Text;
        Int32 AmountDue = Convert.ToInt32((item["AmtDue"].ToString()));
 
 
        string connectionString = ConfigurationManager.ConnectionStrings["foo"].ConnectionString;
        SqlConnection connection = new SqlConnection(connectionString);
 
        try
        {
 
            SqlCommand cmd = new SqlCommand("INSERT INTO Billing (UserID, Type, Date, Description, Amount) VALUES (@UserID, @Type, @Date, @Description, @AmountDue)", connection);
            cmd.Parameters.AddWithValue("@UserID", UserID);
            cmd.Parameters.AddWithValue("@Type", Type);
            cmd.Parameters.AddWithValue("@Date", Date);
            cmd.Parameters.AddWithValue("@Description", Description);
            cmd.Parameters.AddWithValue("@AmountDue", AmountDue);
 
            connection.Open();
            cmd.ExecuteNonQuery();
        }
 
        catch
        {
            Label4.Text = "uh oh";
        }
 
        finally
        {
            connection.Close();
        }
         
 
 
 
 
 
     }
    //Label4.Text = "Fees successfully inserted";
}
Tsvetina
Telerik team
 answered on 01 Jul 2011
8 answers
260 views
Hi there

I realise I could look like a complete idiot but here goes. If I drop a tooltip on my page and leave everything as is except for changing the backcolor, it never actually changes. What am I missing here?

Davy
Marin Bratanov
Telerik team
 answered on 01 Jul 2011
3 answers
132 views
I have a dashboard page that loads four separate RadGrid's. These grids take anywhere from 2 - 8 seconds to load, and they have to load before the page will load. Is there an easy way to have the page load first and then show a loading animation for the time it takes for each of the Grid's to load? 
Tsvetina
Telerik team
 answered on 01 Jul 2011
3 answers
61 views
Hi, I'm working with the RadControls Web App Project as it was easier to build the project, but now my boss is asking why should we use this project instead of using the native ASP.NET Project. Is there a difference between these two? optimization?
One thing I noticed is that I'm having troubles while I try to edit and continue in debug mode, I tried to find the option "Enable Edit and Continue" that native project has but i didn't find it, am I doing something wrong?

Sorry if the english is not that good, Brazil .NET Programmer, hahaha.


Thanks.
Georgi Tunev
Telerik team
 answered on 01 Jul 2011
3 answers
129 views
Please help i use treeview and want to see the node count in the root ex
I want to see this before expanding
Catalogue (3)
Items (2)
Services (4)
---------------------------------------------------------------------------------------------------------------------------------------------
Tree look like this

Catalogue
        Catalogue one
                Catalogue two
                        Catalogue three
Items    
      Item one
            Item Twee
Services 
    Services one
            Services two
                    Service three
                            Service four
Shinu
Top achievements
Rank 2
 answered on 01 Jul 2011
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
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
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?