Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
98 views
Hey,

I was following the example for using a binary image with a listview to display images etc. allowing users to upload, and edit them.

The code is great except in the event the user uploads a bad image, during postback when the listview is displayed it blows up and throws errors saying the binary data is corrupted.

I know there should be a way to grab hold of the data during the ItemDataBound event, and catch the error, and ignore it or substitute the image with something stored on the website like a badimage.jpg

can someone help with this thanks

Andrey
Telerik team
 answered on 10 Jul 2012
5 answers
136 views
Hi all,

If I have a RadGrid hidden on the page (either through setting it's property or doing it dynamically at runtime in Page_Load), and then later make it visible, it looses all it's Skin information.   Here's a quick sample page I created to demonstrate the problem..  I tried also using the RadScriptManager and got the same effect.

Thanks!!

ASP.NET

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="HiddenRadGridTest.aspx.cs" Inherits="HiddenRadGridTest" %> 
 
<%@ 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>Untitled Page</title> 
</head> 
<body> 
    <form id="form1" runat="server"
        &nbsp;<asp:ScriptManager ID="ScriptManager1" runat="server"
        </asp:ScriptManager> 
        &nbsp;<div> 
            <br /> 
            <asp:UpdatePanel ID="UpdatePanel1" runat="server"
                <ContentTemplate> 
                    &nbsp;<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" /> 
                    <telerik:RadGrid ID="RadGrid1" runat="server" DataSourceID="dsTest" GridLines="None" 
                        Visible="False"
                        <ExportSettings> 
                            <Pdf FontType="Subset" PaperSize="Letter" /> 
                            <Excel Format="Html" /> 
                        </ExportSettings> 
                        <MasterTableView AutoGenerateColumns="False" CommandItemDisplay="None" CurrentResetPageIndexAction="SetPageIndexToFirst" 
                            DataKeyNames="CustomerID" DataSourceID="dsTest" Dir="LTR" Frame="Border" TableLayout="Auto"
                            <EditFormSettings> 
                                <EditColumn CurrentFilterFunction="NoFilter" FilterListOptions="VaryByDataType"
                                </EditColumn> 
                            </EditFormSettings> 
                            <Columns> 
                                <telerik:GridBoundColumn CurrentFilterFunction="NoFilter" DataField="CustomerID" 
                                    FilterListOptions="VaryByDataType" ForceExtractValue="None" HeaderText="CustomerID" 
                                    ReadOnly="True" SortExpression="CustomerID" UniqueName="CustomerID"
                                </telerik:GridBoundColumn> 
                                <telerik:GridBoundColumn CurrentFilterFunction="NoFilter" DataField="CustomerName" 
                                    FilterListOptions="VaryByDataType" ForceExtractValue="None" HeaderText="CustomerName" 
                                    SortExpression="CustomerName" UniqueName="CustomerName"
                                </telerik:GridBoundColumn> 
                            </Columns> 
                            <ExpandCollapseColumn CurrentFilterFunction="NoFilter" FilterListOptions="VaryByDataType" 
                                Resizable="False" Visible="False"
                                <HeaderStyle Width="20px" /> 
                            </ExpandCollapseColumn> 
                            <RowIndicatorColumn CurrentFilterFunction="NoFilter" FilterListOptions="VaryByDataType" 
                                Visible="False"
                                <HeaderStyle Width="20px" /> 
                            </RowIndicatorColumn> 
                        </MasterTableView> 
                    </telerik:RadGrid><br /> 
                    &nbsp;<asp:SqlDataSource ID="dsTest" runat="server" ConnectionString="<%$ ConnectionStrings:XXX_ConnectionString %>" 
                        SelectCommand="SELECT * FROM [MyTable]"></asp:SqlDataSource> 
                </ContentTemplate> 
            </asp:UpdatePanel> 
            &nbsp;</div> 
    </form> 
</body> 
</html> 


C# CODEBEHIND
using System; 
using System.Data; 
using System.Configuration; 
using System.Collections; 
using System.Web; 
using System.Web.Security; 
using System.Web.UI; 
using System.Web.UI.WebControls; 
using System.Web.UI.WebControls.WebParts; 
using System.Web.UI.HtmlControls; 
 
public partial class HiddenRadGridTest : System.Web.UI.Page 
    protected void Page_Load(object sender, EventArgs e) 
    { 
         
    } 
    protected void Button1_Click(object sender, EventArgs e) 
    { 
        Button1.Visible = false
        RadGrid1.Visible = true
    } 


Hari Prasad
Top achievements
Rank 1
 answered on 10 Jul 2012
2 answers
189 views
Hi,

I have a problem since few days with the RadCombox on LoadOnDemande.
The load is OK, but when i select an item in the list and i post the page, i have an error message : "Selection out of range Parameter name : Value"

I don't understand the problem, the same code worked before.

Thanks for help

Aspx code :
<telerik:RadComboBox ID="MRLieu" runat="server"
          AllowCustomText="true"
          ItemRequestTimeout="1000"
          Filter="Contains"
          ShowDropDownOnTextboxClick="false"
          MinFilterLength="2"
          EnableLoadOnDemand="true"
          EnableVirtualScrolling="true"
          ShowToggleImage="false"
          OnClientFocus="ChangeOu"
          OnClientItemsRequesting="OnClientItemsRequesting">
           <webservicesettings method="GetLieu" path="~/Utils/WebService/Utils.asmx" />
</telerik:RadComboBox>

JS Code :
function OnClientItemsRequesting(sender, eventArgs) {
    var context = eventArgs.get_context();
    context["coffret"] = "16";
}
 
function ChangeOu(sender) {
    var lieu = $find("MRech_MRLieu");
    lieu.clearSelection();
    lieu.clearItems();
  }


C# Code WS :
[WebMethod]
[ScriptMethod]
public RadComboBoxItemData[] GetLieu(object context)
{
  IDictionary<string, object> contextDictionary = (IDictionary<string, object>)context;
 
  string txt = contextDictionary["Text"].ToString();
  int coffret = Convert.ToInt32(contextDictionary["coffret"]);
 
  txt = txt.Replace("'", " ");
  txt = txt.Replace("\"", " ");
  txt = string.Concat("\"", txt, "*\"");
 
  string sql = @"MyRequest";
 
  ConnexionUtil cnnUtil = new ConnexionUtil();
  DataTable data = cnnUtil.ExecuteRequeteDataTable(sql);
 
  int itemOffset = Convert.ToInt32(contextDictionary["NumberOfItems"]);
  int endOffset = Math.Min(itemOffset + NBITEMS, data.Rows.Count);
 
  List<RadComboBoxItemData> result = new List<RadComboBoxItemData>();
  RadComboBoxItemData itemData;
  for (int i = itemOffset; i < endOffset; i++)
  {
    itemData = new RadComboBoxItemData();
    itemData.Text = data.Rows[i]["nom"].ToString();
    itemData.Value = data.Rows[i]["id"].ToString();
    result.Add(itemData);
  }
 
  data.Dispose();
  cnnUtil.Dispose();
 
  return result.ToArray();
}
mathieu emptoz
Top achievements
Rank 1
 answered on 10 Jul 2012
17 answers
1.5K+ views
I have a rad upload on a user control and i cannot upload my files because after debugging, i found that RadUpload1.UploadedFiles.Count = 0.  i've looked at the examples and I'm at a loss.  My code is below.  What am I missing?

ASPX
<telerik:RadUpload ID="RadUpload1" runat="server" EnableEmbeddedSkins="false" Skin="Hay2" InitialFileInputsCount="3" ControlObjectsVisibility="All" InputSize="75" Width="700px" />

C#
if (RadUpload1.UploadedFiles.Count > 0)
{
    foreach (UploadedFile validFile in RadUpload1.UploadedFiles)
{
    string targetFolder = Server.MapPath("/attachments/");
    validFile.SaveAs(
Path.Combine(targetFolder, validFile.GetName()), true);
}
labelNoResults.Visible =
false;
repeaterValidResults.Visible =
true;
repeaterValidResults.DataSource = RadUpload1.UploadedFiles;
repeaterValidResults.DataBind();
}
else
{
labelNoResults.Visible =
true;
repeaterValidResults.Visible =
false;
}
Peter Filipov
Telerik team
 answered on 10 Jul 2012
1 answer
80 views
I have a page that contains one Button and one Iframe.
The Button opens one popup(jquery dialog) and the Iframe contains one Telerik.ReportViewer.WebForms.
My problem is that when i open the popup that is above the report, the dropdown from the report tools overlaps the popup.
 
  This problem occurs only on internet explorer 6.

P.S. I have noticed that the export feature does not work :(
Steve
Telerik team
 answered on 10 Jul 2012
3 answers
102 views
I am very new at this so, sorry if this is very basic.

I got a rad grid for all my employees and am trying to have a Race, Sex and Classification drop down box to populate the data.

Is there a way to do that right in the editor?

Do I just replace my bound fields with the dropdownboxes and enter the list of available choices somewhere? 

I can not seem to find a way to do this?

Thanks
Matt
Eyup
Telerik team
 answered on 10 Jul 2012
1 answer
96 views
Hello all ,

i've nested radgrid : Radgrid2 into radgrid1

and i want to get the selected row id when "onRowClick" event fires ,

i wrote this js function :   

 function RowClick(sender, eventArgs) {
        var grid = sender;
        var MasterTable = grid.get_masterTableView();
        var row = MasterTable.get_dataItems()[eventArgs.get_itemIndexHierarchical()];
        var cell = MasterTable.getCellByColumnUniqueName(row, "Forum_id");
        alert(cell.innerHTML);
    }
 

the client side code is :
<telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server">
            <telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="true"  OnItemCommand="RadGrid1_ItemCommand" >           
                    <MasterTableView>
                    <NestedViewTemplate>
                        <telerik:RadGrid ID="RadGrid2" runat="server" AllowPaging="True" OnNeedDataSource="RadGrid2_NeedDataSource">                                 
                               <ClientSettings>
                
        <ClientEvents OnRowClick="RowClick"/>
    </ClientSettings>
                       </telerik:RadGrid>
      
                    </NestedViewTemplate>                    
                </MasterTableView>
                <ClientSettings>     
        <ClientEvents OnRowClick="RowClick"/>
    </ClientSettings>
            </telerik:RadGrid>
        </telerik:RadAjaxPanel>

when i click on a row of radgrid1 , js function works rightly .
but when i click on a row of radgrid2 , 2 alert messages appear : the first one gives me the right selected id (what i want ) but the other one gives me the the selected index ..  

how to prevent "onRowClick" event to fire 2 times when i click on radgrid2??  
Tsvetoslav
Telerik team
 answered on 10 Jul 2012
1 answer
102 views
Hi,

I have a RadGrid Control on my WebPage with an editable column.
After edit this column and postback the request, inside the CSharp event

protected void RadAjaxManager1_AjaxRequest(object sender, Telerik.Web.UI.AjaxRequestEventArgs e)
    {
// rg is the RadGrid       
        if (rg != null)
        {
            if (e.Argument == string.Empty)
            {
                rg.Rebind();
            }

            string[] editedItemIds = e.Argument.Split(':');
            int i;
            for (i = 0; i <= editedItemIds.Length - 2; i++)
            {
                try
                {
                    Guid itemId = Guid.Parse(editedItemIds[i]);

//This is the row that give the problem

                    GridDataItem updatedItem = rg.MasterTableView.FindItemByKeyValue("ArticoloId", itemId);
                   
                    UpdateValues(itemId, updatedItem);
                }
                catch
                {
                }
            }
            rg.Rebind();
        }
    }


As told before the rg.MasterTableView.Items collection is empty and so the method "FindItemByKeyValue" does not never return any value.
I follow your example at
http://demos.telerik.com/aspnet-ajax/grid/examples/dataediting/clienteditbatchupdates/defaultcs.aspx

Your help will be much appreciated.
Thanks in advance.

Tsvetoslav
Telerik team
 answered on 10 Jul 2012
3 answers
338 views
Hi, i have been using the RadScheduler for a few Days. I want to Display Data from my Database in the Calendar.

My Table looks like that:

RoomName
Description
From-Date
Until-Date

I want to display these Data in the Calendar. I added a SqlDataSource and established an Connection to my Database. I tested the Query and it works. 

My Question is, how can i use this Data to Display the different Appointments in the Calendar. I only want to display them. No new Insert or Update.


Thanks in advcance
Vijaianand
Top achievements
Rank 1
 answered on 09 Jul 2012
2 answers
189 views
I've been searching through the documentation to do a simple server-side select and access the data in that row. I found this page here (http://www.telerik.com/help/aspnet-ajax/grid-retrieve-primary-key-field-values-for-items.html) and used a line from the sample code:

RadGrid1.SelectedItems[0].GetDataKeyValue("CustomerID").ToString()

Visual Studio gives me an error of "'Telerik.Web.UI.GridItem' does not contain a definition for 'GetDataKeyValue' and no extension method 'GetDataKeyValue' accepting a first argument of type 'Telerik.Web.UI.GridItem' could be found (are you missing a using directive or an assembly reference?)"

I tried a different route using this:

grd.SelectedItems[0].Cells[1].Text

but this doesn't return anything at runtime, regardless of the index I use for the cells collection.

Please advise. Thanks guys!

Darren
Top achievements
Rank 2
 answered on 09 Jul 2012
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?