Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
70 views
Hello i am trying to email the radgrid but i am unable to send it.

Its giving me error when i am trying to change it into Html.

Here is my code.
public void SendPMRSetupGrid(string FromEmail, string ToEmail, string Subject, RadGrid Gridview1) 
        { 
            MailMessage MessageToSend = new MailMessage(FromEmail, ToEmail); 
            MessageToSend.IsBodyHtml = true
            MessageToSend.Subject = Subject; 
            MessageToSend.Body = GridViewToHtml(Gridview1); 
            this.Send(MessageToSend); 
        } 
        private string GridViewToHtml(RadGrid gv) 
        { 
            Page p = new Page(); 
            p.EnableEventValidation = false
            RadScriptManager ScriptManag = new RadScriptManager(); 
            HtmlForm hf = new HtmlForm(); 
            p.Controls.Add(hf); 
            hf.Controls.Add(ScriptManag); 
            hf.Controls.Add(gv); 
            StringBuilder SB = new StringBuilder(); 
            StringWriter stringWrite = new StringWriter(SB); 
            HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite); 
            p.DesignerInitialize(); 
            p.RenderControl(htmlWrite); 
            p = null
            return SB.ToString(); 
        }

I am getting the Exception at p.DesignerInitialize() method saying Request is not available in this context.... When i am using the normal Gridview i have no problem at all for sending it... But when trying to radgrid its throwing this exception.
shahid Aleem
Top achievements
Rank 1
 answered on 27 Feb 2010
14 answers
295 views
Hi,

this is shanker, I am doing one application .I am using filter template 
my code is

   <telerik:GridBoundColumn UniqueName="progress_card_type" DataField="progress_card_type" HeaderText="Progress Card Type" HeaderStyle-Width="200px" >
                        <FilterTemplate>
                            <telerik:RadComboBox ID="RadComboBoxCity" DataSourceID="SqlDataSource1" DataTextField="t"
                                DataValueField="progress_card_type_id" Height="100px" AppendDataBoundItems="true" SelectedText='<%# ((GridItem)Container).OwnerTableView.GetColumn("progress_card_type").CurrentFilterValue %>'
                                runat="server" OnClientSelectedIndexChanged="CityIndexChanged" >
                                <Items>
                                    <telerik:RadComboBoxItem Text="All" />
                                </Items>
                            </telerik:RadComboBox>
                            <telerik:RadScriptBlock ID="RadScriptBlock2" runat="server">

                                <script type="text/javascript">
                                    function CityIndexChanged(sender, args) 
                                    {
                                        var tableView = $find("<%# ((GridItem)Container).OwnerTableView.ClientID %>");
                                        tableView.filter("progress_card_type", args.get_item().get_text(), "EqualTo");
                                    }
                                </script>

                            </telerik:RadScriptBlock>
                        </FilterTemplate>

<HeaderStyle Width="200px"></HeaderStyle>
                    </telerik:GridBoundColumn>


it's not working properly please send any solutions and  here i want text filed and value filed of rad combobox how to get that 


thanks and regards
shanker.b
shanker bangari
Top achievements
Rank 1
 answered on 27 Feb 2010
2 answers
122 views
Hi,

My requirement is when ever am check the check box some control is enable is true and check box is false that control enable false 


am using this code 

 CheckBox chech = (((Telerik.Web.UI.GridDataItem)(grdprogresssetup.EditItems[0]))).EditFormItem.FindControl("showattendance") as CheckBox;
                if (chech.Checked == true)
                {
                    RadComboBox rdp_start_date = (((Telerik.Web.UI.GridDataItem)(grdprogresssetup.EditItems[0]))).EditFormItem.FindControl("rdp_start_date") as RadComboBox;
                    RadComboBox rdp_end_date = (((Telerik.Web.UI.GridDataItem)(grdprogresssetup.EditItems[0]))).EditFormItem.FindControl("rdp_end_date") as RadComboBox;
                    rdp_start_date.Enabled = true;
                    rdp_end_date.Enabled = true;
                }
                else
                {
                    RadComboBox rdp_start_date = (((Telerik.Web.UI.GridDataItem)(grdprogresssetup.EditItems[0]))).EditFormItem.FindControl("rdp_start_date") as RadComboBox;
                    RadComboBox rdp_end_date = (((Telerik.Web.UI.GridDataItem)(grdprogresssetup.EditItems[0]))).EditFormItem.FindControl("rdp_end_date") as RadComboBox;
                    rdp_start_date.Enabled = false;
                    rdp_end_date.Enabled = false;
                }

But it's work only edit mode i want both insert and update 

how to solve that 

thanks and regards

shanker.B
shanker bangari
Top achievements
Rank 1
 answered on 27 Feb 2010
2 answers
144 views
Hi,

I need your help, pleas.. I'm trying  to edit some fields in my detailsview and it works fine except the RadDateTimePicker.
I used it in the EditItemTemplate as below:

<asp:TemplateField HeaderText="IN">  
                <EditItemTemplate>  
                    <telerik:RadDateTimePicker ID="RadDateTimePicker1" Runat="server"   
                        AutoPostBackControl='<%# bind("CHECKIN") %>' Culture="English (United States)"   
                        Enabled='<%# bind("CHECKIN") %>' SharedCalendar='<%# bind("CHECKIN") %>'   
                        SharedTimeView='<%# bind("CHECKIN") %>' Visible='<%# bind("CHECKIN") %>' >  
                         
                    </telerik:RadDateTimePicker>  
                </EditItemTemplate>  
                 
                <ItemTemplate>  
                    <asp:Label ID="Label1" runat="server" Text='<%# eval("CHECKIN") %>' DataFormatString="{0:MM/DD/YYYY HH:MI:SS AM}"  
                    HtmlEncode="false">  
                    </asp:Label>  
                </ItemTemplate>  
                  
            </asp:TemplateField>  

and i get this error:
System.InvalidCastException: Conversion from type 'Date' to type 'Integer' isnot valid.

i tried to solve this by many ways but all of them didn't work

I think the problem is in the data binding method but i couldn't find the correct format?

I appreciate your reply, Thanks 
Reem Reem
Top achievements
Rank 1
 answered on 27 Feb 2010
6 answers
119 views
I'm using Telerik Radcontrol and I have some problems with radgrid filtering controls. I want to use a dropdownlist control insted of a textfield and a filter image button. But my code doesn't work. Here my code, please help me:
Default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="tryFilter._Default" %> 
 
<%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %> 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
 
<html xmlns="http://www.w3.org/1999/xhtml" > 
<head runat="server"
    <title></title
</head> 
<body> 
    <form id="form1" runat="server"
    <div> 
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server"
        </telerik:RadScriptManager> 
    
     
        <telerik:RadGrid ID="RadGrid1" runat="server" AllowFilteringByColumn="True"  
            AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False"  
            DataSourceID="SqlDataSource1" GridLines="None" Skin="Outlook"
<MasterTableView cellspacing="-1" datakeynames="ProductID" datasourceid="SqlDataSource1"
<RowIndicatorColumn> 
<HeaderStyle Width="20px"></HeaderStyle> 
</RowIndicatorColumn> 
 
<ExpandCollapseColumn> 
<HeaderStyle Width="20px"></HeaderStyle> 
</ExpandCollapseColumn> 
    <Columns> 
        <telerik:GridBoundColumn DataField="ProductName" HeaderText="ProductName"  
            SortExpression="ProductName" UniqueName="ProductName"
        </telerik:GridBoundColumn> 
        <telerik:GridBoundColumn DataField="UnitsOnOrder" DataType="System.Int16"  
            HeaderText="UnitsOnOrder" SortExpression="UnitsOnOrder"  
            UniqueName="UnitsOnOrder"
        </telerik:GridBoundColumn> 
        <telerik:GridTemplateColumn DataField="Discontinued" HeaderText="Discontinued"  
            UniqueName="column"
            <EditItemTemplate> 
                <asp:TextBox ID="DiscontinuedTextBox" runat="server"  
                    Text='<%# Bind("Discontinued") %>'></asp:TextBox> 
            </EditItemTemplate> 
            <ItemTemplate> 
                <asp:Label ID="DiscontinuedLabel" runat="server"  
                    Text='<%# Eval("Discontinued") %>'></asp:Label> 
            </ItemTemplate> 
            <FilterTemplate> 
                <asp:DropDownList ID="cbbDiscontinued" AutoPostBack="true"  
                        OnSelectedIndexChanged="cbbDiscontinued_SelectedIndexChanged" runat="server"
                    <asp:ListItem Text="All" Value="-1"></asp:ListItem> 
                    <asp:ListItem Text="Active" Value="1"></asp:ListItem> 
                    <asp:ListItem Text="Lock" Value="0"></asp:ListItem> 
                </asp:DropDownList> 
            </FilterTemplate> 
        </telerik:GridTemplateColumn> 
    </Columns> 
</MasterTableView> 
        </telerik:RadGrid> 
        <asp:SqlDataSource ID="SqlDataSource1" runat="server"  
            ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"  
            SelectCommand="SELECT * FROM [Products]"
        </asp:SqlDataSource> 
    
     
    </div> 
    </form> 
</body> 
</html> 
 
Default.aspx.cs
using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Web; 
using System.Web.UI; 
using System.Web.UI.WebControls; 
using Telerik.Web; 
using Telerik.Web.UI; 
 
namespace tryFilter 
    public partial class _Default : System.Web.UI.Page 
    { 
        protected void Page_Load(object sender, EventArgs e) 
        { 
 
        } 
 
        protected void cbbDiscontinued_SelectedIndexChanged(object sender, EventArgs e) 
        { 
            DropDownList cbbDiscontinued=(DropDownList)sender; 
            this.RadGrid1.Columns[2].CurrentFilterValue = cbbDiscontinued.SelectedValue; 
            this.RadGrid1.Columns[2].CurrentFilterFunction = GridKnownFunction.EqualTo; 
            this.RadGrid1.Rebind(); 
        } 
    } 
 

tom cat
Top achievements
Rank 1
 answered on 27 Feb 2010
2 answers
137 views
I have 3 image buttons and a label. when i click on 2 of the 3 image buttons, the label gets updated with the appropriate text. when i click on the other, i get an error. they are exactly the same (from what i can see). here is the code (snippits):

When you click on the 2nd or 3rd image (ibCourse16 or ibCourse20), it works fine. When you click on the first (ibCourse17) you get an error.

You can also go to www.americance.com. From the home page in the 'Electrician' area, choose 'North Carolina' and any of the license types. Click the red 'Next'. FIRST: click on the middle image (NEC Grounding and Bonding Part I). The text at the bottom of the page changes. Click the third image (NEC Grounding and Bonding Part 2) - same result..all is ok. Click the first image. The text does not change and you see the 'Error on Page' at the bottom of the browser.

If I take this out of AJAX for course 17, I don't get an error, so it has something to do with that. However, it works for image 16 and 20.
 <telerik:AjaxUpdatedControl ControlID="CourseCatalogDesc" />

 


I'm stuck....
Thanks,
Susan

 

 

<table cellpadding=0 cellspacing=0 id="tblCourse17" width="240px" bgcolor="#E9EAEC" runat="server">

 

 

 

 

 

    <tr>

 

 

 

 

 

        <td class="NormalBold" align="center" style="padding-bottom:5px; padding-top:5px">NEC 2008 Fundamentals</td></tr>

 

 

 

 

 

 

    <tr>

 

 

 

 

 

        <td class="Normal" align="center">$40.00 / 4 Hour Course</td></tr>

 

 

 

 

 

    <tr>

 

 

 

 

 

        <td height="7px"></td></tr>

 

 

 

 

 

 

    <tr>

 

 

 

 

 

        <td align="center">

 

 

 

 

 

            <asp:ImageButton ID="ibCourse17" ImageUrl="images/bookimages/nc2008nectextbookcover.jpg" runat="server" /></td></tr>

 

 

 

 

 

    <tr>

 

 

 

 

 

        <td height="5px"></td></tr>

 

 

 

 

 

    <tr>

 

 

 

 

 

        <td align="center" style="padding-bottom:5px">

 

 

 

 

 

            <asp:button ID="btnCourse17" Text="Add to Cart" runat="Server" /></td></tr>

 

 

 

 

 

 

 

</table>

 

 

 

 

 

<table cellpadding=0 cellspacing=0 id="tblCourse16" width="240px" runat="server">

 

 

 

 

 

    <tr>

 

 

 

 

 

        <td class="NormalBold" align="center" style="padding-bottom:5px; padding-top:5px">NEC Grounding and Bonding</td></tr>

 

 

 

 

 

 

    <tr>

 

 

 

 

 

        <td class="Normal" align="center">$40.00 / 4 Hour Course</td></tr>

 

 

 

 

 

    <tr>

 

 

 

 

 

        <td height="7px"></td></tr>

 

 

 

 

 

 

    <tr>

 

 

 

 

 

        <td align="center">

 

 

 

 

 

            <asp:ImageButton ID="ibCourse16" ImageUrl="images/bookimages/ncgroundingbonding1.jpg" runat="server" /></td></tr>

 

 

 

 

 

    <tr>

 

 

 

 

 

        <td height="5px"></td></tr>

 

 

 

 

 

    <tr>

 

 

 

 

 

        <td align="center" style="padding-bottom:5px">

 

 

 

 

 

 

 

 

    <tr>

 

 

 

 

 

        <td align="center" style="padding-bottom:5px">

 

 

 

 

 

            <asp:button ID="btnCourse16" Text="Add to Cart" runat="Server" /></td></tr>

 

 

 

 

 

 

 

</table>

 

 

 

 

 

<table cellpadding=0 cellspacing=0 id="tblCourse20" width="240px" runat="Server">

 

 

 

 

 

    <tr>

 

 

 

 

 

        <td class="NormalBold" align="center" style="padding-bottom:5px; padding-top:5px">NEC Grounding and Bonding 2</td></tr>

 

 

 

 

 

 

    <tr>

 

 

 

 

 

        <td class="Normal" align="center">$40.00 / 4 Hour Course</td></tr>

 

 

 

 

 

    <tr>

 

 

 

 

 

        <td height="7px"></td></tr>

 

 

 

 

 

 

    <tr>

 

 

 

 

 

        <td align="center">

 

 

 

 

 

            <asp:ImageButton ID="ibCourse20" ImageUrl="images/bookimages/ncgroundingbonding2.jpg" runat="server" /></td></tr>

 

 

 

 

 

    <tr>

 

 

 

 

 

        <td height="5px"></td></tr>

 

 

 

 

 

    <tr>

 

 

 

 

 

        <td align="center" style="padding-bottom:5px">

 

 

 

 

 

            <asp:button ID="btnCourse20" Text="Add to Cart" runat="Server" /></td></tr>

 

 

 

 

 

 

</table>

 

 

 


THE LABEL
<

 

tr>

 

 

<td valign=top>

 

 

 

<asp:Label ID="CourseCatalogDesc" Runat="server" CssClass="Normal" /> </td></tr>

AJAX CODE

 

 

 

<telerik:AjaxSetting AjaxControlID="ibCourse16">

 

 

 

    <UpdatedControls>

 

 

 

        <telerik:AjaxUpdatedControl ControlID="CourseCatalogDesc" />

 

 

 

        <telerik:AjaxUpdatedControl ControlID="tblCourse17"/>

 

 

 

        <telerik:AjaxUpdatedControl ControlID="tblCourse16"/>

 

 

 

        <telerik:AjaxUpdatedControl ControlID="tblCourse20"/>

 

 

 

    </UpdatedControls>

 

 

 

 </telerik:AjaxSetting>

 

 

 

 

 

 

<telerik:AjaxSetting AjaxControlID="ibCourse20">

 

 

 

     <UpdatedControls>

 

 

 

         <telerik:AjaxUpdatedControl ControlID="CourseCatalogDesc" />

 

 

 

         <telerik:AjaxUpdatedControl ControlID="tblCourse17"/>

 

 

 

         <telerik:AjaxUpdatedControl ControlID="tblCourse16"/>

 

 

 

         <telerik:AjaxUpdatedControl ControlID="tblCourse20"/>

 

 

 

     </UpdatedControls>

 

 

 

 </telerik:AjaxSetting>

 

 

 

 

 

 

<telerik:AjaxSetting AjaxControlID="ibCourse17">

 

 

 

     <UpdatedControls>

 

 

 

         <telerik:AjaxUpdatedControl ControlID="CourseCatalogDesc" />

 

 

 

         <telerik:AjaxUpdatedControl ControlID="tblCourse16"/>

 

 

 

         <telerik:AjaxUpdatedControl ControlID="tblCourse20"/>

 

 

 

         <telerik:AjaxUpdatedControl ControlID="tblCourse17"/>

 

 

 

     </UpdatedControls>

 

 

 

 </telerik:AjaxSetting>

 

Susan
Top achievements
Rank 1
 answered on 27 Feb 2010
2 answers
92 views
When a create an event non recurring and set time frame, it save it as an all day event.
The starttime and endtime is always set to 12:00.

I am using advanced from.


Sarah
Top achievements
Rank 1
 answered on 27 Feb 2010
2 answers
154 views
I am implementing the delete event.
I cannot delete an event.
I get the following exception:

Cannot locate the parent of appointment with ID = '3'. Ensure that the parent appointment with ID = '0' exists and is loaded. 

Any ideas.
Sarah
Top achievements
Rank 1
 answered on 27 Feb 2010
2 answers
221 views
Hi,
I am trying to create a user control to achieve multi select combo box functionality using RadComboBox. When click on check box of a combo box item i get System.Data.DataRowView instead of actual text value. Here are my code and pl help.

MultiSelectCombo.ascx
===================

<

 

telerik:RadComboBox runat="server" Skin="Web20" ID="RadComboBox1" Height="190px" Width="420px"

 

 

MarkFirstMatch="true"

 

 

EnableLoadOnDemand="true"

 

 

HighlightTemplatedItems="true"

 

 

OnClientItemsRequested="UpdateItemCountField"

 

 

OnDataBound="RadComboBox1_DataBound"

 

 

OnItemsRequested="RadComboBox1_ItemsRequested">

 

 

<ItemTemplate>

 

 

<asp:CheckBox runat="server" ID="chk1" onclick="onCheckBoxClick(this);" />

 

 

<asp:Label runat="server" ID="Label1" AssociatedControlID="chk1"><%# Eval("CodeDesc")%>

 

 

</asp:Label>

 

 

</ItemTemplate>

 

 

<FooterTemplate>

 

A total of

<asp:Literal runat="server" ID="RadComboItemsCount" /> items

 

 

</FooterTemplate>

 

 

</telerik:RadComboBox>

MultiSelectCombo.ascx.cs
=====================

 

public

 

partial class MultiSelectCombo : BaseControl

 

{

 

protected void Page_Load(object sender, EventArgs e)

 

{

 

if (!Page.ClientScript.IsClientScriptBlockRegistered("MultiSelectComboIDBlock"))

 

{

Page.ClientScript.RegisterClientScriptBlock(

this.Page.GetType(), "MultiSelectComboIDBlock", "var MultiSelectComboID = '" + RadComboBox1.ClientID + "';", true);

 

}

}

 

protected void RadComboBox1_DataBound(object sender, EventArgs e)

 

{

 

//set the initial footer label

 

 

 

 

((

Literal)RadComboBox1.Footer.FindControl("RadComboItemsCount")).Text = Convert.ToString(RadComboBox1.Items.Count);

 

}

 

protected void RadComboBox1_ItemsRequested(object sender, RadComboBoxItemsRequestedEventArgs e)

 

{

RadComboBox1.DataSource =

Shared.tdsStaticReference.User;

 

RadComboBox1.DataBind();

}

}

 

MultiSelectCombo.js
================

 

function

 

UpdateItemCountField(sender, args) {

 

 

//set the footer text

 

 

 

 

 

sender.get_dropDownElement().lastChild.innerHTML =

"A total of " + sender.get_items().get_count() + " items";

 

}

 

 

var cancelDropDownClosing = false;

 

 

function onDropDownClosing() {

 

cancelDropDownClosing =

false;

 

}

 

function onCheckBoxClick(chk) {

 

 

var combo = $find(MultiSelectComboID);

 

alert(combo);

 

//prevent second combo from closing

 

 

 

 

 

cancelDropDownClosing =

true;

 

 

//holds the text of all checked items

 

 

 

 

 

 

var text = "";

 

 

//holds the values of all checked items

 

 

 

 

 

 

var values = "";

 

 

//get the collection of all items

 

 

 

 

 

 

var items = combo.get_items();

 

 

//enumerate all items

 

 

 

 

 

 

for (var i = 0; i < items.get_count(); i++) {

 

 

var item = items.getItem(i);

 

 

 

//get the checkbox element of the current item

 

 

 

 

 

 

var chk1 = $get(combo.get_id() + "_i" + i + "_chk1");

 

 

if (chk1.checked) {

 

text += item.get_text() +

";";

 

values += item.get_value() +

",";

 

}

}

 

//remove the last comma from the string

 

 

 

 

 

text = removeLastSemicolon(text);

values = removeLastComma(values);

 

if (text.length > 0) {

 

 

//set the text of the combobox

 

 

 

 

 

combo.set_text(text);

combo.set_value(values);

}

 

else {

 

 

//all checkboxes are unchecked

 

 

 

 

 

 

//so reset the controls

 

 

 

 

 

combo.set_text(

"");

 

combo.set_value(

"");

 

}

}

 

 

//this method removes the ending comma from a string

 

 

 

 

 

 

function removeLastComma(str) {

 

 

return str.replace(/,$/, "");

 

}

 

function removeLastSemicolon(str) {

 

 

return str.replace(/;$/, "");

 

}

 

function OnClientDropDownClosingHandler(sender, e) {

 

 

//do not close the second combo if

 

 

 

 

 

 

//a checkbox from the first is clicked

 

 

 

 

 

e.set_cancel(cancelDropDownClosing);

}

 


 

donoho
Top achievements
Rank 1
 answered on 26 Feb 2010
1 answer
120 views
ddlRoles.SelectedValue = "User"

Trying to set the value of a RadComboBox(ddlRoles).  The value exists in the combo box, but it is not being selected.  Is this a known issue at all?
Matt
Top achievements
Rank 1
 answered on 26 Feb 2010
Narrow your results
Selected tags
Tags
+? more
Top users last month
Simon
Top achievements
Rank 2
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
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?