I am trying to use GridAttachemntColumn in grid with batcheditng. i tried to find out the file name in prior to store in db. but not able to do it.please find code snippet for further detail.
protected void gridProjectManagement_BatchEditCommand(object sender, GridBatchEditingEventArgs e)
{
int s = e.Commands.Count();
foreach (GridBatchEditingCommand command in e.Commands)
{
Hashtable newValues = command.NewValues;
Hashtable oldValues = command.OldValues;
//RadAsyncUpload rd = command.Item["Attachment"].Controls[0] as RadAsyncUpload;
//string file = rd.UploadedFiles[0].FileName;
//command.Item.EditManager.GetColumnEditor("Attachment")
//var gridAttachmentColumnEditor = ((GridAttachmentColumnEditor)command.Item.EditManager.GetColumnEditor("Attachment"));
//string file = gridAttachmentColumnEditor.RadUploadControl.UploadedFiles[0].GetName();
string id = (string)newValues["ID"];
//Convert.ToInt64(newValues["ID"].ToString());
// string newFirstName = newValues["PerspectiveRating"].ToString();
if (!string.IsNullOrEmpty(id))
{
var OldeItem = ListActivityArchivalSupportPM.Where(x => x.ID == Convert.ToInt32(id)).FirstOrDefault();
using (var db = new EntitiesModel())
{
var p = db.ActivityArchivalSupportPMs.Where(x => x.ID == Convert.ToInt32(id)).FirstOrDefault();
if (newValues["Estimate"] != null)
{
p.Estimate = Convert.ToDecimal(newValues["Estimate"].ToString());
}
p.Activity = (string)newValues["Activity"];
p.EstimateAssumptions = (string)newValues["EstimateAssumptions"];
p.ApplicationID = AppName.Value;
if (newValues["FileName"] != null)
{
p.Attachment = (Byte[])newValues["FileName"];
}
<
telerik:RadGrid
ID
=
"gridProjectManagement"
GridLines
=
"None"
runat
=
"server"
AllowAutomaticDeletes
=
"false"
AllowAutomaticInserts
=
"True"
AllowSorting
=
"true"
AllowFilteringByColumn
=
"true"
FilterType
=
"CheckList"
EnableLinqExpressions
=
"false"
OnItemCreated
=
"gridProjectManagement_ItemCreated"
OnPreRender
=
"gridProjectManagement_PreRender"
AllowAutomaticUpdates
=
"True"
AutoGenerateColumns
=
"False"
OnBatchEditCommand
=
"gridProjectManagement_BatchEditCommand"
OnItemCommand
=
"gridProjectManagement_ItemCommand"
OnNeedDataSource
=
"gridProjectManagement_NeedDataSource"
OnItemDataBound
=
"gridProjectManagement_ItemDataBound"
>
<
ExportSettings
ExportOnlyData
=
"true"
HideStructureColumns
=
"true"
OpenInNewWindow
=
"true"
IgnorePaging
=
"true"
><
Excel
Format
=
"Html"
/></
ExportSettings
>
<
MasterTableView
CommandItemDisplay
=
"Top"
DataKeyNames
=
"ID"
Font-Size
=
"Small"
CommandItemSettings-ShowAddNewRecordButton
=
"false"
CommandItemSettings-ShowRefreshButton
=
"false"
HorizontalAlign
=
"NotSet"
EditMode
=
"Batch"
AutoGenerateColumns
=
"False"
AllowFilteringByColumn
=
"True"
>
<
CommandItemSettings
ShowExportToCsvButton
=
"true"
ShowExportToExcelButton
=
"true"
ShowAddNewRecordButton
=
"true"
ShowExportToPdfButton
=
"true"
ShowExportToWordButton
=
"true"
/>
<
BatchEditingSettings
EditType
=
"Cell"
OpenEditingEvent
=
"Click"
/>
<%-- <
SortExpressions
>
<
telerik:GridSortExpression
FieldName
=
"PerspModel_ID"
SortOrder
=
"Descending"
/>
</
SortExpressions
>--%>
<
Columns
>
<
telerik:GridBoundColumn
DataField
=
"ID"
ForceExtractValue
=
"Always"
Display
=
"false"
HeaderText
=
"ID"
UniqueName
=
"ID"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"Activity"
AllowSorting
=
"true"
SortExpression
=
"Activity"
HeaderStyle-Width
=
"150px"
HeaderText
=
"Activity"
UniqueName
=
"Activity"
>
</
telerik:GridBoundColumn
>
<
telerik:GridNumericColumn
DataField
=
"Estimate"
HeaderStyle-Width
=
"80px"
AllowFiltering
=
"false"
AllowSorting
=
"false"
DataType
=
"System.Decimal"
DecimalDigits
=
"1"
HeaderText
=
"Estimate(hours)"
SortExpression
=
"Estimate"
UniqueName
=
"Estimate"
>
</
telerik:GridNumericColumn
>
<
telerik:GridTemplateColumn
ColumnEditorID
=
"EstimateAssumptions"
ItemStyle-CssClass
=
"breakWord120"
UniqueName
=
"EstimateAssumptions"
ItemStyle-Width
=
"100px"
AllowFiltering
=
"false"
HeaderStyle-Width
=
"150px"
HeaderText
=
"Estimate Assumptions"
>
<
ItemTemplate
>
<%# Eval("EstimateAssumptions")%>
</
ItemTemplate
>
<
EditItemTemplate
>
<
telerik:RadTextBox
ID
=
"txtEditEstimateAssumptions"
Height
=
"50px"
Wrap
=
"true"
TextMode
=
"MultiLine"
ToolTip='<%# Eval("EstimateAssumptions")%>' runat="server" Text='<%# Eval("EstimateAdjustmentRationale")%>'></
telerik:RadTextBox
>
</
EditItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridAttachmentColumn
EditFormHeaderTextFormat
=
"Upload File:"
HeaderStyle-Width
=
"150px"
HeaderText
=
"Attachment"
AttachmentDataField
=
"Attachment"
AttachmentKeyFields
=
"ID"
FileNameTextField
=
"FileName"
DataTextField
=
"FileName"
UniqueName
=
"Attachment"
>
</
telerik:GridAttachmentColumn
>
</
Columns
>
</
MasterTableView
>
<
ClientSettings
>
<
Scrolling
AllowScroll
=
"true"
UseStaticHeaders
=
"true"
ScrollHeight
=
"300px"
SaveScrollPosition
=
"true"
></
Scrolling
>
<%-- <
ClientEvents
OnBatchEditOpened
=
"OnBatchEditOpened"
OnBatchEditOpening
=
"BatchEditOpening"
/>--%>
<%-- <
ClientEvents
OnCommand
=
"gridCommand"
></
ClientEvents
>--%>
</
ClientSettings
>
</
telerik:RadGrid
>