Telerik Forums
UI for ASP.NET AJAX Forum
4 answers
156 views
 am creating an itemtemplate all dynamic and adding text box ...i also looked to this link: http://www.telerik.com/help/aspnet-ajax/grid-programmatic-creation.html but the coding is too dense ..  

please help me with my code 

  int colCnt = ds.Tables[0].Columns.Count;
            int rowCnt = ds.Tables[0].Rows.Count;

 GridBoundColumn boundColumn;
   boundColumn = new GridBoundColumn();
           

 RadGrid1.MasterTableView.Columns.Add(boundColumn);
            boundColumn.DataField = ds.Tables[0].Columns[0].ColumnName ;
            boundColumn.HeaderText = ds.Tables[0].Columns[0].ColumnName;
            GridTemplateColumn templateColumn;
            for (int i = 1; i < colCnt; i++)
            {
             
                templateColumn = new GridTemplateColumn();
                templateColumn . --> am clueless over here ....can u guyz me ! 

                RadGrid1.MasterTableView.Columns.Add(templateColumn);
                boundColumn.DataField = ds.Tables[0].Columns[i].ColumnName;
                boundColumn.HeaderText = ds.Tables[0].Columns[i].ColumnName;
            }

Kshitiz
Top achievements
Rank 1
 answered on 09 May 2012
1 answer
112 views
Why doesn't sorting work when you bind an IEnumerable<T> collection that uses the yield keyword?  Do I have to implement a custom paging solution?  I am using 2012 Q1 SP1 controls.

<telerik:RadGrid ID="RadGrid1" runat="server" OnNeedDataSource="RadGrid1_NeedDataSource">
    <MasterTableView AllowSorting="true" AllowPaging="true" PageSize="20" AllowFilteringByColumn="true" />
</telerik:RadGrid>

using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Data.Linq;
using System.Linq;
 
using Telerik.Web.UI;
 
public class Class1
{
    public Class1(int i)
    {
        this.Column1 = i.ToString();
        this.Column2 = (200 - i).ToString();
        this.Column3 = System.Text.Encoding.Default.GetString(new[] { System.Convert.ToByte(65 + (i % 26)) });
    }
 
    public string Column1 { get; set; }
    public string Column2 { get; set; }
    public string Column3 { get; set; }
 
    public static IEnumerable<Class1> GetData()
    {
        List<Class1> data = new List<Class1>();
 
        for (int i = 0; i < 200; i++)
        {
            yield return new Class1(i);
        }
    }
}
 
public partial class Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
    }
 
    protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
    {
        //RadGrid1.DataSource = Class1.GetData().ToArray();  //works
        RadGrid1.DataSource = Class1.GetData();  //doesn't work
    }
}
Tsvetina
Telerik team
 answered on 09 May 2012
1 answer
109 views
Hello,

I am trying to embed a RadMenu inside a RadComboBox. Everything works fine until I try to configure the combobox to request items only after at least three characters have been entered into the filter. Once I set the EnableAutomaticLoadOnDemand to "true" I get the error attached.

My code is below. Please advise on possible steps to resolve this issue.
<telerik:RadComboBox ID="RadComboBox4" runat="server" Width="590px" Height="140px"
    Filter="Contains" ShowToggleImage="False" EmptyMessage="Fund..." MinFilterLength="3" EnableAutomaticLoadOnDemand="True"
    DataSourceID="SqlDataSource1" DataTextField="Name" DataValueField="FundID"
    OnItemDataBound="RadComboBox4_ItemDataBound" >
    <ItemTemplate>
        <div style="float: left">
            <asp:Label ID="Label1" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "Name") %>'></asp:Label>
        </div>
        <div style="float: right">
            <telerik:RadMenu ID="RadMenu1" runat="server" EnableRoundedCorners="true" EnableShadows="true" >
                <Items>
                    <telerik:RadMenuItem Text="Fund ID">
                        <GroupSettings ExpandDirection="Right"></GroupSettings>
                        <Items>
                            <telerik:RadMenuItem Text="About US">
                            </telerik:RadMenuItem>
                            <telerik:RadMenuItem Text="Strategic Plan">
                            </telerik:RadMenuItem>
                            <telerik:RadMenuItem Text="Executive Bios">
                            </telerik:RadMenuItem>
                            <telerik:RadMenuItem Text="Contact Us">
                            </telerik:RadMenuItem>
                        </Items>
                    </telerik:RadMenuItem>
                </Items>
            </telerik:RadMenu>
        </div>
        <br /><br />
    </ItemTemplate>
</telerik:RadComboBox>

Dimitar Terziev
Telerik team
 answered on 09 May 2012
2 answers
125 views
I have a sharepoint 2007 controltemplate and have created a rotator which works fine as long as it is in the page when I put it in a .js file I can reference the controls but not set the properties. it always returns an error. I have tried several different ways and some things work and some do not. Any help appreciated...I basically took the script attached and removed the script reference and called it rotator.js
Slav
Telerik team
 answered on 09 May 2012
1 answer
107 views
I copied your demo "Grid /Update/Insert/Delete In Hierarchy" aspx and vb code into a solution I created for using a custom skin. I have an aspx page with a number of your controls so I can see how they will look with my custom skin DLL. What I am seeing with this multi-level grid is the icons don't always show up. Sometimes all I get is the empty box with an "X" and the text default for the icon. This not only happens with my custom skin but with the canned skins from Telerik. I may have to do several screen refreshes to get the icons to show. I can't figure out what is causing this to happen. If you want my solution, let me know and I will open a support ticket so I can send you a zip file.
Martin
Telerik team
 answered on 09 May 2012
3 answers
228 views
hi
 
i have a RadAsyncUpload which enables users to upload videos, i need to get thumbnails for each uploaded video, any help ?
Jhansi
Top achievements
Rank 1
 answered on 09 May 2012
3 answers
103 views
Hi,

RedEditor Underline not wrking in ie9,button is disabled ,not able to underline the text.
Please replyASAP,it's urgent



Regards
Ajay
Rumen
Telerik team
 answered on 09 May 2012
2 answers
102 views

How To restrict RadNumericTextbox  DecimalSeparator=". , "
I restrict both of then


Thanks Advance,
Mohamed.
mohamed
Top achievements
Rank 1
 answered on 09 May 2012
4 answers
112 views

Hi

I am using a hierarchical grid to show parent child data, when I update the parent record it is easy to use code behind running on the EditCommand event to grab some values for inserting back in to the record on update and it works well.

However I cant work out how to make the E
ditCommand event to fire in the child grid? I assume that as the DetailTables use another GridView to show the data that it would have access to the same events but I dont know how to access that event in my aspx.vb code

Thx for any advice you can give


Kind regards

Dwight
Dwight
Top achievements
Rank 1
 answered on 09 May 2012
1 answer
187 views
Hi Telerik,

Below is my code.  Before I add OnclientvalidationFailed event and specify MaxFileSize, everything works fine.  However, after I added this event, the code in my onclientfileuploaded does not function well.

What happened was -
(1), (3), (5) are still on the list, while I am expecting only (1), (3) on the list.

Steps to reproduce an error -
(1) upload a good file - e.g. Doc1
(2) upload a file which is more than 2 mb
(3) upload a different good file - e.g. doc2
(4) upload a too large file
(5) upload (1)'s file

This is very urget.  Please kindly help.

Thanks!

Joan




HTML -

<

 

 

div id="uploadDiv" class="uploadDiv">

 

<telerik:radasyncupload id="inputFile" runat="server" temporaryfileexpiration="02:00:00" MaxFileSize="2097152"

 

allowedfileextensions="gif,png,jpg,jpeg,bmp,pdf,doc,docx,csv,xls,xlsx,xlt,txt,rtf,msg,ppt,pptx,msi"

 

onclientfileselected="OnFileSelected" onclientfilesuploaded="OnFilesUploaded"

 

onclientprogressupdating="OnProgressUpdating" onclientfileuploaded="OnFileUploaded"

 

onclientfileuploadremoved="OnFileUploadRemoved" OnClientValidationFailed="OnClientValidationFailed"

 

OnClientFileUploadFailed="OnFileUploadFailed"

 

>

Javascript -

 

<

 

 

 

 

 

 

 

 

script type="text/javascript">

 

 

 

 

 

var MAX_TOTAL_BYTES = 2097152;

 

 

 

 

 

var filesSize = new Array();

 

 

 

 

 

var OVERSIZE_MESSAGE = "Maximum total upload size is 2MB";

 

 

 

 

 

var isDuplicateFile = false;

 

 

 

 

 

var fileCount = 0;

 

 

 

 

 

var uploadingFiles =[];

 

 

 

 

 

var uploadsInProgress = 0; //add new code - start

 

 

 

 

 

function OnFileSelected(sender, args) {

 

 

 

 

 

for (var fileindex in sender._uploadedFiles) {

 

 

 

 

 

if (sender._uploadedFiles[fileindex].fileInfo.FileName == args.get_fileName()) {

isDuplicateFile =

 

 

 

 

 

true;

}

}

 

 

 

 

 

//add new code - start

 

 

 

 

 

if (!uploadsInProgress) {

}

uploadsInProgress++;

 

 

 

 

 

//add new code - end

}

 

 

 

 

 

function OnFilesUploaded(sender, args) {

 

 

 

 

 

if (sender._uploadedFiles.length == 0) {

filesSize =

 

 

 

 

 

new Array();

 

 

 

 

 

//add new code - start

uploadsInProgress = 0;

 

 

 

 

 

//add new code - end

}

 

 

 

 

 

//add new code - start

 

 

 

 

 

if (uploadsInProgress > 0) {

DecrementUploadsInProgress();

}

 

 

 

 

 

//add new code - end

}

 

 

 

 

 

function OnProgressUpdating(sender, args) {

filesSize[args.get_data().fileName] = args.get_data().fileSize;

 

}

 

 

 

 

 

function OnFileUploaded(sender, args) {

 

 

 

 

 

/*original code

var totalBytes = 0;

var numberOfFiles = sender._uploadedFiles.length;

if (isDuplicateFile) {

sender.deleteFileInputAt(numberOfFiles - 1);

isDuplicateFile = false;

sender.updateClientState();

if (args.get_fileName() != null)

{ alert(args.get_fileName() + ' ' + 'already exists.'); }

else

{ alert('File already exists.'); }

return;

}

for (var index in filesSize) {

totalBytes += filesSize[index];

}

if (totalBytes > MAX_TOTAL_BYTES) {

sender.deleteFileInputAt(numberOfFiles - 1);

sender.updateClientState();

alert(OVERSIZE_MESSAGE);

}

*/

 

 

 

 

 

 

 

//sender.set_enabled(true);

 

 

 

 

 

var totalBytes = 0;

 

 

 

 

 

var wrongfileIndex = null;

 

 

 

 

 

var numberOfFiles = sender._uploadedFiles.length;

 

 

 

 

 

var deletedFileName = null;

 

 

 

 

 

if (isDuplicateFile) {

 

 

 

 

 

//replace with the following

 

 

 

 

 

var col = sender.getUploadedFiles();

 

 

 

 

 

for (var fileindex in sender.getUploadedFiles()) {

 

 

 

 

 

if (col[fileindex] == args.get_fileName()) {

wrongfileIndex = fileindex;

 

 

 

 

 

if (wrongfileIndex != null) {

 

 

 

 

 

if (deletedFileName == null) {

deletedFileName = args.get_fileName();

sender.deleteFileInputAt(wrongfileIndex);

}

 

 

 

 

 

else {

 

 

 

 

 

if (deletedFileName == args.get_fileName()) {

deletedFileName=

 

 

 

 

 

null;

}

}

}

}

}

isDuplicateFile =

 

 

 

 

 

false;

sender.updateClientState();

 

 

 

 

 

if (args.get_fileName() != null)

{ alert(args.get_fileName() +

 

 

 

 

 

' ' + 'already exists.'); }

 

 

 

 

 

else

{ alert(

 

 

 

 

 

'File already exists.'); }

col = sender.getUploadedFiles();

 

 

 

 

 

return;

}

 

 

 

 

 

for (var index in sender._uploadedFiles) {

totalBytes += sender._uploadedFiles[index].fileInfo.ContentLength;

}

 

 

 

 

 

if (totalBytes > MAX_TOTAL_BYTES) {

 

 

 

 

 

//sender.deleteFileInputAt(numberOfFiles - 1);

 

 

 

 

 

//replace with the following

 

 

 

 

 

var col = sender.getUploadedFiles();

 

 

 

 

 

for (var fileindex in sender.getUploadedFiles()) {

 

 

 

 

 

if (col[fileindex] == args.get_fileName()) {

wrongfileIndex = fileindex;

 

 

 

 

 

if (wrongfileIndex != null) {

sender.deleteFileInputAt(wrongfileIndex);

}

}

}

col = sender.getUploadedFiles();

sender.updateClientState();

col = sender.getUploadedFiles();

alert(OVERSIZE_MESSAGE);

}

}

 

 

 

 

 

function OnFileUploadRemoved(sender, args) {

 

 

 

 

 

if (args.get_fileName() != null) {

 

 

 

 

 

if (!isDuplicateFile) {

 

 

 

 

 

delete filesSize[args.get_fileName()];

}

 

 

}

}

 

 

 

 

 

function OnFileUploadFailed(sender, args) {

DecrementUploadsInProgress();

}

 

 

 

 

 

function ConfigureSuccessfullyUploadedMessage(docName) {

$ = $telerik.$;

 

 

 

 

 

var attPanel = $(".info-panel");

 

 

 

 

 

var divs = attPanel[0].all;

 

 

 

 

 

for (var i = 0; i < divs.length; i++) {

 

 

 

 

 

var element = divs[i];

 

 

 

 

 

if (element.innerText == docName) {

element.style.display =

 

 

 

 

 

"none";

 

 

 

 

 

if (fileCount > 0) {

fileCount = fileCount - 1;

}

}

}

}

 

 

 

 

 

function OnClientFileUploading(sender, args) {

 

 

 

 

 

/*$telerik.$(".ruCancel").bind('click', function (e) {

$telerik.$(this).parent().remove();

});*/

 

 

}

 

 

 

 

 

function OnClientValidationFailed(sender, eventArgs) {

 

 

 

 

 

/*original code

alert('Wrong file type: ' + eventArgs.get_fileName());

$telerik.$(eventArgs.get_row()).css("display", "none");

*/

 

 

 

 

 

 

 

//check if validation fails because of wrong extenstion

 

 

 

 

 

if(!checkFileExt(eventArgs.get_fileName()))

{

alert(

 

 

 

 

 

'Wrong file type: ' + eventArgs.get_fileName());

}

 

 

 

 

 

else

{

alert(OVERSIZE_MESSAGE +

 

 

 

 

 

'. ' + eventArgs.get_fileName() + ' is too large.');

}

$telerik.$(eventArgs.get_row()).css(

 

 

 

 

 

"display", "none");

}

 

 

 

 

 

function checkFileExt(elem) {

 

 

 

 

 

var filePath = elem;

 

 

 

 

 

if (filePath.indexOf('.') == -1)

 

 

 

 

 

return false;

 

 

 

 

 

var validExtensions = new Array();

 

 

 

 

 

var ext = filePath.substring(filePath.lastIndexOf('.') + 1).toLowerCase();

validExtensions[0] =

 

 

 

 

 

'gif';

validExtensions[1] =

 

 

 

 

 

'png';

validExtensions[2] =

 

 

 

 

 

'jpg';

validExtensions[3] =

 

 

 

 

 

'jpeg';

validExtensions[4] =

 

 

 

 

 

'bmp';

validExtensions[5] =

 

 

 

 

 

'pdf';

validExtensions[6] =

 

 

 

 

 

'doc';

validExtensions[7] =

 

 

 

 

 

'docx';

validExtensions[8] =

 

 

 

 

 

'csv';

validExtensions[9] =

 

 

 

 

 

'xls';

validExtensions[10] =

 

 

 

 

 

'xlsx';

validExtensions[11] =

 

 

 

 

 

'xlt';

validExtensions[12] =

 

 

 

 

 

'txt';

validExtensions[13] =

 

 

 

 

 

'rtf';

validExtensions[14] =

 

 

 

 

 

'msg';

validExtensions[15] =

 

 

 

 

 

'ppt';

validExtensions[16] =

 

 

 

 

 

'pptx';

validExtensions[16] =

 

 

 

 

 

'msi';

 

 

 

 

 

for (var i = 0; i < validExtensions.length; i++) {

 

 

 

 

 

if (ext == validExtensions[i])

 

 

 

 

 

return true;

}

 

 

 

 

 

return false;

}

 

 

 

 

 

//add new code - start

 

 

 

 

 

function DecrementUploadsInProgress() {

uploadsInProgress--;

 

 

 

 

 

if (!uploadsInProgress) {

$telerik.$(

 

 

 

 

 

".ruBrowse").removeAttr("disabled");

$telerik.$(

 

 

 

 

 

".ruFakeInput").removeAttr("disabled");

 

}

}

 

 

 

 

 

//add new code - end

 

 

 

 

 

function OnClientAdded(sender, args) {

alert(

 

 

 

 

 

'Added');

}

 

 

 

 

 

//occurs when file commence uploading

 

 

 

 

 

function OnClientFileUploading(sender, eventArgs) {

 

 

 

 

 

//cancel the upload

 

 

 

 

 

//eventArgs.set_cancel(true);//not working

alert(

 

 

 

 

 

'no duplicate file: ' + args.get_fileName());

 

 

 

 

 

//hide the uploading item

$telerik.$(eventArgs.get_row()).css(

 

 

 

 

 

"display", "none");

 

 

 

 

 

//check if uploading files contain the new updating file

 

 

 

 

 

var _containDuplicateFile = false;

 

 

 

 

 

if (uploadingFiles != null && uploadingFiles.length > 0) {

 

 

 

 

 

for (var i = 0; i < uploadingFiles.length; i++) {

 

 

 

 

 

if (uploadingFiles[i] == args.get_fileName()) {

_containDuplicateFile =

 

 

 

 

 

true;

 

 

 

 

 

break;

}

}

}

 

 

 

 

 

if (_containDuplicateFile) {

 

 

 

 

 

//cancel the upload

args.set_cancel(

 

 

 

 

 

true);

alert(

 

 

 

 

 

'no duplicate file: ' + args.get_fileName());

 

 

 

 

 

//hide the uploading item

$telerik.$(args.get_row()).css(

 

 

 

 

 

"display", "none");

}

 

 

 

 

 

else if (!_containDuplicateFile) {

uploadingFiles[args.get_fileName()] = args.get_fileName();

}

}

 

 

 

 

 

</script>

 

 

 

Plamen
Telerik team
 answered on 09 May 2012
Narrow your results
Selected tags
Tags
+? more
Top users last month
Boardy
Top achievements
Rank 2
Veteran
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
ivory
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
ClausDC
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Boardy
Top achievements
Rank 2
Veteran
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
ivory
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
ClausDC
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?