Hello,
I have a grid with row BatchEditMode and GridTemplateColumn with RadAsyncUpload in Edittemplate. I try to save file to fileserver on OnBatchEditCommand, but I can not access to RadAsyncUpload from code behind.
<
telerik:RadGrid
runat
=
"server"
Skin
=
"Metro"
RenderMode
=
"Lightweight"
ID
=
"gvAuditorium"
AutoGenerateColumns
=
"False"
DataSourceID
=
"dsAuditorium"
AllowAutomaticDeletes
=
"false"
AllowAutomaticInserts
=
"False"
AllowAutomaticUpdates
=
"False"
AllowPaging
=
"True"
OnBatchEditCommand
=
"gvAuditorium_OnBatchEditCommand"
>
<
MasterTableView
DataKeyNames
=
"RoomId"
PageSize
=
"50"
EditMode
=
"Batch"
CommandItemDisplay
=
"TopAndBottom"
>
<
CommandItemSettings
ShowAddNewRecordButton
=
"False"
ShowRefreshButton
=
"False"
></
CommandItemSettings
>
<
BatchEditingSettings
EditType
=
"Row"
OpenEditingEvent
=
"Click"
></
BatchEditingSettings
>
<
Columns
>
<
telerik:GridBoundColumn
DataField
=
"Number"
SortExpression
=
"Number"
UniqueName
=
"Number"
HeaderText
=
"Номер аудитории"
ReadOnly
=
"True"
></
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"RoomName"
SortExpression
=
"RoomName"
UniqueName
=
"RoomName"
HeaderText
=
"Название"
ReadOnly
=
"True"
></
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"TypeRoomName"
SortExpression
=
"TypeRoomName"
UniqueName
=
"TypeRoomName"
HeaderText
=
"Тип аудитории"
ReadOnly
=
"True"
></
telerik:GridBoundColumn
>
<
telerik:GridNumericColumn
DataField
=
"Square"
SortExpression
=
"Square"
UniqueName
=
"Square"
DataFormatString
=
"{0:N2}"
DecimalDigits
=
"2"
HeaderText
=
"Площадь"
/>
<
telerik:GridNumericColumn
DataField
=
"PlaceCount"
SortExpression
=
"PlaceCount"
UniqueName
=
"PlaceCount"
DecimalDigits
=
"0"
DataFormatString
=
"{0:0}"
HeaderText
=
"Количество мест"
/>
<
telerik:GridTemplateColumn
DataField
=
"ScanFileName"
UniqueName
=
"ScanFileName"
HeaderText
=
"План аудитории"
>
<
ItemTemplate
>
<
asp:HyperLink
runat
=
"server"
ID
=
"hlToFile"
Target
=
"_blank"
Visible='<%# Eval("hasFile") %>' Text='<%# Bind("ScanFileName") %>' NavigateUrl='<%# "~/_layouts/15/FastAuditoriumFilling/AuditoriumFileDownload.aspx?RoomId=" + Eval("RoomId") %>' ></
asp:HyperLink
>
</
ItemTemplate
>
<
EditItemTemplate
>
<
telerik:RadAsyncUpload
runat
=
"server"
ID
=
"auFileUpload"
Skin
=
"Metro"
RenderMode
=
"Lightweight"
AllowedFileExtensions
=
"pdf"
></
telerik:RadAsyncUpload
>
</
EditItemTemplate
>
</
telerik:GridTemplateColumn
>
</
Columns
>
</
MasterTableView
>
</
telerik:RadGrid
>
protected
void
gvAuditorium_OnBatchEditCommand(
object
sender, GridBatchEditingEventArgs e)
{
if
(e.Commands.Count > 0)
{
foreach
(var editingCommand
in
e.Commands)
{
int
roomId = (
int
)editingCommand.Item.GetDataKeyValue(
"RoomId"
);
Hashtable newValues = editingCommand.NewValues;
RadAsyncUpload auFileUpload = gvAuditorium.FindControl(gvAuditorium.MasterTableView.ClientID +
"_ScanFileName"
).FindControl(
"auFileUpload"
)
as
RadAsyncUpload;
if
(auFileUpload !=
null
&& auFileUpload.UploadedFiles.Count > 0)
{
//SAVE FILE
}
//SAVE DATA TO DB
}
}
}
If e.Commands.Count == 1, then all OK, but if e.Commands.Count > 1 then RadAsyncUpload auFileUpload = gvAuditorium.FindControl(gvAuditorium.MasterTableView.ClientID +"_ScanFileName").FindControl("auFileUpload") as RadAsyncUpload; get always first edit control.
How can I save files from all edited lines?