This is a migrated thread and some comments may be shown as answers.

Upload in radgrid

1 Answer 48 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Qixiong Zhen
Top achievements
Rank 1
Qixiong Zhen asked on 22 Apr 2010, 06:03 PM
Dear telerik team
My case is like this:
I have a table, which has column Author, Filename,
The table will be display in rad grid view.
Initially, the table is empty, when user click a button on the grid view, the rad upload control appear. then user can upload the file to a folder in server side and save the file name and author to table in back end.
The grid view will display the input from the table.

I have read some example such as :
  http://demos.telerik.com/aspnet-ajax/controls/examples/integration/raduploadinajaxifiedgrid/defaultcs.aspx?product=upload

What confuse me in the above example is :
1 I can see the control radUpload  in the apsx file;
2 in c# code, 

    protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
        {
            if (e.Item is GridEditableItem && e.Item.IsInEditMode)
            {
                GridBinaryImageColumnEditor editor =   ((GridEditableItem)e.Item).EditManager.GetColumnEditor("Upload") as GridBinaryImageColumnEditor;
                TableCell cell = (TableCell)editor.RadUploadControl.Parent;
                CustomValidator validator = new CustomValidator();
                validator.ErrorMessage = "Please select file to be uploaded";
                validator.ClientValidationFunction = "validateRadUpload";
                validator.Display = ValidatorDisplay.Dynamic;
                cell.Controls.Add(validator);
            }
        }

How to get the "editor", if column is not a image column.

If you have a good example code, that is much better to help me.

Thanks a lot!

Qixiong

1 Answer, 1 is accepted

Sort by
0
Martin
Telerik team
answered on 28 Apr 2010, 11:48 AM
Hello Qixiong Zhen,

Generally, you can use the same approach for all the different editable columns (those that implement the IGridEditableColumn interface). The only difference would be the column editor type. For example the GridBoundColumn, by default provides a GridTextBoxColumnEditor for each cell. Here is how the code looks for this column type:

protected void  RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
{
    if (e.Item is GridEditableItem && e.Item.IsInEditMode)
    {
        GridTextBoxColumnEditor editor =   ((GridEditableItem)e.Item).EditManager.GetColumnEditor("MyBoundColumn") as GridTextBoxColumnEditor;
    }
}

For more information about the default column editors that the different column types provide, please check the following help article:

Column types

I hope this helps,
Martin
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Ajax
Asked by
Qixiong Zhen
Top achievements
Rank 1
Answers by
Martin
Telerik team
Share this question
or