Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
143 views

Hello.  I'm trying to get a simple RadGrid to work, but am not having any luck.  Support (for which I paid extra) is only giving my cryptic responses and seems unwilling to make a few lines' adjustments to my code to show me how to get started using the grid.

Attached is my RadGrig page.  I want to have a drop-down box during edit mode for the "category" field.  The two tables are:

TbGilFloProItem (item)

gf__id int Unchecked
gf__name varchar(100) 
gf__category int 
gf__image_name varchar(50) 

and

TbGilFloProCat (cat)

id int 
title nvarchar(50) 

The cat.id should be the value for item.category, but cat.title should be what's seen in non-edit mode (non-combobox) and in drop-down during edit.

The item.image is an "upload" during edit mode.  The image is uploading fine and my code is scaling and creating a thumbnail fine.  But... neither the CATEGORY nor IMAGE NAME is getting updated.

Can someone please look at the ASPX and CS code and put in some working sample code to get me started?  I've gone through the suggestions for support, but have had no luck.

Any assistance would be greatly appreciated!



ASPX page...


<%

@ Page Title="" Language="C#" MasterPageFile="~/Masters/Site.Master" AutoEventWireup="True" CodeBehind="EditGalleryItem.aspx.cs" Inherits="MyProject.EditGalleryItem" %>

 

<%

@ Register assembly="Telerik.OpenAccess, Version=2009.1.405.1, Culture=neutral, PublicKeyToken=7ce17eeaf1d59342" namespace="Telerik.OpenAccess" tagprefix="telerik" %>

 

<%

@ Register assembly="Telerik.Web.UI, Version=2009.1.402.35, Culture=neutral, PublicKeyToken=121fae78165ba3d4" namespace="Telerik.Web.UI" tagprefix="telerik" %>

 

<

 

asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">

 

 

<script type="text/javascript" src="../javascript/prototype.js"></script>

 

<

 

script type="text/javascript" src="../javascript/scriptaculous.js?load=effects,builder"></script>

 

<

 

script type="text/javascript" src="../javascript/lightbox.js"></script>

 

<

 

link rel="stylesheet" href="../css/lightbox.css" type="text/css" media="screen" />

 

<

 

style type="text/css">

 

 

.MyImageButton

 

{

 

cursor: hand;

 

}

 

.EditFormHeader td

 

{

 

font-size: 14px;

 

 

padding: 4px !important;

 

 

color: #0066cc;

 

}

 

.RadGrid .rgEditForm .RadComboBox

 

{

 

width:100px !important;

 

}

 

</style>

 

</

 

asp:Content>

 

<

 

asp:Content ID="Content3" runat="server"

 

 

contentplaceholderid="ContentPlaceHolder_sidebar">

 

 

</

 

asp:Content>

 

<

 

asp:Content ID="Content4" runat="server"

 

 

contentplaceholderid="ContentPlaceHolder_content">

 

 

<div class="content_1col">

 

 

<telerik:radajaxmanager ID="RadAjaxManager1" runat="server">

 

 

<ajaxsettings>

 

 

<telerik:AjaxSetting AjaxControlID="RadGrid1">

 

 

<updatedcontrols>

 

 

<telerik:AjaxUpdatedControl ControlID="RadGrid1" />

 

 

</updatedcontrols>

 

 

</telerik:AjaxSetting>

 

 

</ajaxsettings>

 

 

</telerik:radajaxmanager>

 

 

<telerik:radscriptblock ID="RadScriptBlock1" runat="server">

 

 

<script type="text/javascript">

 

 

//On insert and update buttons click temporarily disables ajax to perform upload actions

 

 

function conditionalPostback(e, sender) {

 

 

var theRegexp = new RegExp("\.UpdateButton$|\.PerformInsertButton$", "ig");

 

 

if (sender.EventTarget.match(theRegexp)) {

 

 

var upload = $find(window['UploadId']);

 

 

//AJAX is disabled only if file is selected for upload

 

 

if (upload.getFileInputs()[0].value != "") {

 

sender.EnableAjax =

false;

 

}

}

}

 

</script>

 

 

</telerik:radscriptblock>

 

 

<asp:HiddenField ID="ComboValue" runat="server" />

 

 

<telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server"

 

 

ClientEvents-OnRequestStart="conditionalPostback" Width="700px">

 

 

<telerik:RadProgressManager ID="RadProgressManager1" runat="server" />

 

 

<telerik:RadProgressArea ID="RadProgressArea1" runat="server">

 

 

</telerik:RadProgressArea>

 

 

<telerik:RadGrid ID="RadGrid1" runat="server" AllowAutomaticDeletes="True" AllowAutomaticInserts="True"

 

 

AllowAutomaticUpdates="True" AllowPaging="True" AllowSorting="True"

 

 

DataSourceID="OpenAccessDataSource1" GridLines="None" OnItemDataBound="RadGrid1_ItemDataBound"

 

 

AutoGenerateColumns="False" OnUpdateCommand="RadGrid1_UpdateCommand"

 

 

OnInsertCommand="RadGrid1_InsertCommand" Width="750px" height="450px" >

 

 

<mastertableview editmode="PopUp" datakeynames="GfId" datasourceid="OpenAccessDataSource1">

 

 

<Columns>

 

 

<telerik:GridEditCommandColumn>

 

 

</telerik:GridEditCommandColumn>

 

 

<telerik:GridTemplateColumn HeaderText="Name" UniqueName="ImageName" SortExpression="GfName">

 

 

<ItemTemplate>

 

 

<asp:Label runat="server" ID="lblName" Text='<%# Eval("GfName") %>' />

 

 

</ItemTemplate>

 

 

<EditItemTemplate>

 

 

<asp:TextBox runat="server" ID="txbName" Text='<%# Bind("GfName") %>' />

 

 

<asp:RequiredFieldValidator ID="Requiredfieldvalidator1" runat="server" ControlToValidate="txbName"

 

 

ErrorMessage="Name is required" Display="Dynamic" SetFocusOnError="true">

 

 

</asp:RequiredFieldValidator>

 

 

</EditItemTemplate>

 

 

</telerik:GridTemplateColumn>

 

 

<telerik:GridTemplateColumn HeaderText="Category" UniqueName="Category"

 

 

DataField="GfCategory" Visible="True">

 

 

<ItemTemplate>

 

 

<asp:Label runat="server" ID="labName">

 

<%

# DataBinder.Eval(Container.DataItem, "GfCategory")%>

 

 

</asp:Label>

 

 

</ItemTemplate>

 

 

<EditItemTemplate>

 

 

 

<telerik:RadComboBox ID="RadComboBox1" Runat="server"

 

 

DataSourceID="OpenAccessDataSource2" DataTextField="Title" DataValueField="Id"

 

 

Skin="Hay">

 

 

</telerik:RadComboBox>

 

 

 

</EditItemTemplate>

 

 

</telerik:GridTemplateColumn>

 

 

<telerik:GridTemplateColumn HeaderText="Image" UniqueName="Upload">

 

 

<ItemTemplate>

 

 

<a href="../images/gallery/scaled/<%# Eval("GfImageName") %>" rel="lightbox" title="<%# Eval("GfName") %>">

 

<

 

asp:Image runat="server" ID="ImageThumbnail" AlternateText='<%# Eval("GfName") %>'

 

ImageUrl

 

='<%# "~/images/gallery/thumb/" + Eval("GfImageName")%>' Style="border-width: 0px;" />

 

 

</a>

 

 

</ItemTemplate>

 

 

<EditItemTemplate>

 

 

<telerik:RadUpload ID="RadUpload1" Runat="server" InputSize="20"

 

 

MaxFileInputsCount="1" Skin="Forest"

 

 

TargetFolder="~/images/uploads" AllowedFileExtensions=".jpg,.gif,.png"

 

 

InitialFileInputsCount="14"

 

 

ControlObjectsVisibility="None">

 

 

</telerik:RadUpload>

 

 

</EditItemTemplate>

 

 

</telerik:GridTemplateColumn>

 

 

<telerik:GridButtonColumn HeaderText="Delete" Text="Delete" CommandName="Delete"

 

 

UniqueName="column">

 

 

</telerik:GridButtonColumn>

 

 

</Columns>

 

 

<EditFormSettings>

 

 

<EditColumn UniqueName="EditCommandColumn1">

 

 

</EditColumn>

 

 

</EditFormSettings>

 

 

<ExpandCollapseColumn>

 

 

<HeaderStyle Width="20px" />

 

 

</ExpandCollapseColumn>

 

 

<RowIndicatorColumn>

 

 

<HeaderStyle Width="20px" />

 

 

</RowIndicatorColumn></mastertableview>

 

 

<clientsettings>

 

 

<scrolling allowscroll="True" usestaticheaders="True" />

 

 

</clientsettings>

 

 

</telerik:RadGrid>

 

 

</telerik:RadAjaxPanel>

 

 

<telerik:openaccessdatasource ID="OpenAccessDataSource1" runat="server"

 

 

EnableDelete="True" EnableInsert="True" EnableUpdate="True"

 

 

ObjectContextProvider="MyProject.ObjectScopeProvider1, GillespiesFlowers"

 

 

TypeName="PersistentClasses.TbGilFloProItem" Where="" ContextTypeName="" OrderBy="">

 

 

</telerik:openaccessdatasource>

 

 

<telerik:openaccessdatasource ID="OpenAccessDataSource2" runat="server"

 

 

EnableDelete="True" EnableInsert="True" EnableUpdate="True"

 

 

ObjectContextProvider="MyProject.ObjectScopeProvider1, GillespiesFlowers"

 

 

TypeName="PersistentClasses.TbGilFloProCat" Where="">

 

 

</telerik:openaccessdatasource>

 

 

</div>

 

</

 

asp:Content>

 


CS page...

 

using

 

System;

 

 

 

 

using

 

System.Collections.Generic;

 

 

 

 

using

 

System.Linq;

 

 

 

 

using

 

System.Web;

 

 

 

 

using

 

System.Web.UI;

 

 

 

 

using

 

System.Web.UI.WebControls;

 

 

 

 

using

 

System.IO;

 

 

 

 

using

 

System.Drawing;

 

 

 

 

using

 

Telerik.Web.UI;

 

 

 

 

namespace

 

MyProject {

 

 

public partial class EditGalleryItem : BasePage {

 

 

//protected void Page_Load(object sender, EventArgs e) {

 

 

 

 

 

 

// base.Page_Load(sender, e);

 

 

 

 

 

 

//}

 

 

 

 

 

 

protected void RadGrid1_UpdateCommand(object source, GridCommandEventArgs e) {

 

InitializeUpdateParameter((RadUpload)e.Item.FindControl(

"RadUpload1"));

 

 

}

 

 

protected void RadGrid1_InsertCommand(object source, GridCommandEventArgs e) {

 

InitializeUpdateParameter((RadUpload)e.Item.FindControl(

"RadUpload1"));

 

}

 

private void InitializeUpdateParameter(RadUpload currentUpload) {

 

 

string pathFull = Server.MapPath("~/images/gallery/full/");

 

 

string pathScaled = Server.MapPath("~/images/gallery/scaled/");

 

 

string pathThumb = Server.MapPath("~/images/gallery/thumb/");

 

 

if (currentUpload.UploadedFiles.Count > 0) {

 

 

foreach (UploadedFile validFile in currentUpload.UploadedFiles) {

 

 

//string targetFolder = Server.MapPath("~/images/uploads");

 

 

 

 

 

 

// Read uploaded file stream, scale and save

 

 

 

 

 

 

//string[] fileNameArray = GetFileNameArray(validFile.GetName());

 

 

 

 

 

 

//string filenameOnly = fileNameArray[0];

 

 

 

 

 

 

//string extensionOnly = fileNameArray[1];

 

 

 

 

 

 

string filename = validFile.GetName();

 

 

// Save uploaded file (full size)

 

 

 

 

 

validFile.SaveAs(

Path.Combine(pathFull, filename), true);

 

 

// Save thumbnail

 

 

 

 

 

Bitmap thumbImage = Globals.ResizeBitmap(

new Bitmap(validFile.InputStream), 75, 100);

 

thumbImage.Save(

Path.Combine(pathThumb, filename));

 

 

// Save scaled image

 

 

 

 

 

Bitmap scaledImage = Globals.ProportionallyResizeBitmap(

new Bitmap(validFile.InputStream), 750, 575);

 

scaledImage.Save(

Path.Combine(pathScaled, filename));

 

 

// Delete original full-size uploaded file

 

 

 

 

 

 

//File.Delete(Path.Combine(targetFolder, validFile.GetName()));

 

 

 

 

 

}

 

 

 

//if (currentUpload.UploadedFiles.Count > 0) {

 

 

 

 

 

 

// byte[] data = new byte[currentUpload.UploadedFiles[0].ContentLength];

 

 

 

 

 

 

// currentUpload.UploadedFiles[0].InputStream.Read(data, 0, data.Length);

 

 

 

 

 

 

// Session["DataCS"] = data;

 

 

 

 

 

 

//

 

 

 

 

 

}

}

 

protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) {

 

 

if (e.Item is GridEditableItem && e.Item.IsInEditMode) {

 

RadComboBox control = ((Telerik.Web.UI.GridEditableItem)(e.Item))[

"Category"].FindControl("RadComboBox1") as RadComboBox;

 

 

string selectedValue = Convert.ToString(DataBinder.Eval(e.Item.DataItem, "GfCategory"));

 

control.SelectedValue = selectedValue;

//here should be the ID.

 

 

 

 

 

RadUpload upload = (RadUpload)e.Item.FindControl(

"RadUpload1");

 

RadAjaxPanel1.ResponseScripts.Add(

string.Format("window['UploadId'] = '{0}';", upload.ClientID));

 

}

}

}

}

Georgi Krustev
Telerik team
 answered on 18 May 2009
1 answer
64 views
hi
This is karthik from visual consultancy service bangalore..

i face problem with  rad editor toll bar.. i have to give only for font name arial but now its listing more than 6 i dont want this much.. how can i do.. pls help me...
bye
pl.karthik
vcs bangalore
Rumen
Telerik team
 answered on 18 May 2009
1 answer
105 views
I'm using the AJAX RadGrid 2008.3.1314 and I'm experiencing the following problem with the arrows which appear when you are dragging a column into the grouping panel. If, before doing the drop, you move the mouse below the grouping panel, the arrows disappear. However, if you do the same thing but move the mouse above the grouping panel, the arrows do not disappear. This misleads the user into thinking they have dropped the column into the panel, thus initiating grouping.

Is this a known problem? Is there a simple workaround?

Thanks,
Mike

P.S. I wanted to add a screen shot of the page in question to this entry. How do I do that?
Sebastian
Telerik team
 answered on 18 May 2009
1 answer
69 views

hi
This is karthik from visual consultancy service bangalore..

i face problem with  rad editor toll bar.. i have to give only for font name arial but now its listing more than 6 i dont want this much.. how can i do.. pls help me...
pl.karthik
vcs bangalore

Rumen
Telerik team
 answered on 18 May 2009
5 answers
212 views
hi

i have a datagrid that uses a nested view template , and i am having trouble getting it to filter the data it displays , inside the nested view template are 2 tabs each with a data grid , and basically i want to filter the data in those grids based on the data in the main data grid.

its basic staff data , the main grid displays the core data , the tabs display role information and contact information respectively.

i am using a dataset to populate the grids , there are 3 tables in the dataset , staff data,staff roles,staff contact info , i have built all the relations , as well as following the heiracy examples , but it still wont filter the data , each table has a PersonID field in it , and i have put the ParentTableRelation in , but it wont filter , can you please offer any assistance.
Sebastian
Telerik team
 answered on 18 May 2009
1 answer
110 views
Hey,

Ive seen the posts that solve this problem all over the place, and read them and implemented the suggestions to try and get the editor working to be enabled but no luck

The ImageManager button is enabled but the manager itself has all its buttons "greyed out".
I'm pretty certain I've set up the manager correctly, and I have set the right permissions in iis and on the folder itself.

Here is the code relating to the problem:
-------------------------------------------------------------------------------
<telerik:RadEditor ID="form_htmleditor" runat="server" Skin="Telerik" Width="750px" Height="300px" EditModes="Design, Html" NewLineBr="true">
                         <ImageManager UploadPaths="~/uploads/media/image/" DeletePaths="~/uploads/media/image/" ViewPaths="~/uploads/media/image/" EnableImageEditor="true" SearchPatterns="*.jp" />
                        <Tools>........
-------------------------------------------------------------------------------

Thanks for taking a look.



Simon
Top achievements
Rank 1
 answered on 18 May 2009
1 answer
107 views
Hi,

I used  RadCalendar.NET2 ( Version: 2.2.1.0, Runtime Version: v2.0.50727)

I am using RadDatpicker Inside RadGrid.
I used CustomValidator to validate Date entered(typed into built in date inputbox) /selected(from calendar).

We have situation here:

When user changes date using Shared Calendar:

When user selects date using shared Calendar and if selected date does not belongs to validate range than associate ClientValidationFunction fire properly (e.g only once as it should be). Everything works fine.

When user  changes date by typing into built-in Date input box:

When user changes date by typing into built-in date input box of Rad Date picker and if date does not belongs to validate date range, ClientValidationFunction fires twice. This create the problem. It should fire once only.

BTW:  here is design code and javascript function that I used to validate entered/selected date.

<Design>

 <EditItemTemplate>
                                                                                            <radCln:RadDatePicker ID="rdTransactionDate" runat="server" Width="110px" MinDate="1960/1/1"
                                                                                                MaxDate="2099/1/1" Calendar-Skin="Default2006" UseEmbeddedScripts="false">
                                                                                            </radCln:RadDatePicker>
                                                                                            <asp:CustomValidator ID="cvTransactionDate" runat="server" ClientValidationFunction="CheckDate"
                                                                                                ControlToValidate="rdTransactionDate" SetFocusOnError ="true" ></asp:CustomValidator>
                                                                                        </EditItemTemplate>
</Design>

<script language="javascript">
function CheckDate(source, arguments)
    {
        try
        {
            var ControlName = source.id;
            var objDate = document.getElementById(ControlName.replace('cvTransactionDate','rdTransactionDate')).value;
            
            var objYear = document.getElementById('ctl00_CntAdminBody_cmbyear');
            var objCurYear = parseInt(objYear.value);
            
            var objMinYear = objCurYear - 1;
            var objMinDate = objMinYear + '-07-01';
            var objMaxDate = objCurYear + '-06-30';
            
            arguments.IsValid = true;
            
            if(objDate < objMinDate || objDate > objMaxDate)
            {
                alert("Enter Date Between FinancialYear");
                arguments.IsValid = false;
            }
            
        }
        catch(e)
        {
        }
       
    }



</script>

Please let me know what might be wrong here and also if there is any solution.

Best Regards,
Gaurav
Iana Tsolova
Telerik team
 answered on 18 May 2009
0 answers
76 views
Hello,

I wasn't able to run a pagemethod that is implemented on a usercontrol named "dummy.ascx"  with Treeview. After I moved my Service method to a dummy page, it worked correctly. Do you think that I failed somewhere or was it expected?

If it was normal, I wounder do you plan to make it works with usercontrol?

Kind Regards.

Aytaç Utku TOPAL
Aytaç Utku TOPAL
Top achievements
Rank 2
 asked on 18 May 2009
2 answers
85 views

  I have a custom Advanced edit panel and I would like users double clicking to be able to do the following two functions:

1) Remove the ability for users to double click to create a new appointment.
2) Ability to go straight to the Advanced insert form without having to choose Options first.

Thanks!
Alex Occhipinti
Top achievements
Rank 1
 answered on 18 May 2009
1 answer
210 views

My company just purchased the Telerik Premium Collection for .NET and asked me to start making some charts that are due in a few days. I have no experience with Telerik or reporting in general so I need as much help as I can get.

I have a database table that represents each developer’s time scheduled by project managers. It has the following fields:
Employee, Date, Hours, Project Code

My manager wants a stacked bar chart that has the date on the X axis and hours on the Y axis. Each bar would show the number of hours scheduled that day grouped by project code. He wants the chart to show one employee at a time with the ability to switch to different employees. The dates on the X axis would show the current week with the ability to scroll to the right to see future dates scheduled, up to 3 months. Also, he wants you to be able to hover over the bar chart to see the project code related to those hours.

Velin
Telerik team
 answered on 18 May 2009
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?