I followed the example online to download the attachment from a grid with a GridAttachmentColumn but I can't get the download working. The postback fires, ajax disables but the file is not sent. I am using Entity Framework.
<
telerik:RadGrid
AutoGenerateColumns
=
"False"
AutoGenerateDeleteColumn
=
"True"
AutoGenerateEditColumn
=
"True"
DataSourceID
=
"EntityAttachmentsDataSource"
ID
=
"EntityAttachmentsGrid"
OnDeleteCommand
=
"EntityAttachmentsGrid_OnDeleteCommand"
OnInsertCommand
=
"EntityAttachmentsGrid_OnInsertCommand"
OnItemCommand
=
"EntityAttachmentsGrid_OnItemCommand"
OnUpdateCommand
=
"EntityAttachmentsGrid_OnUpdateCommand"
runat
=
"server"
>
<
MasterTableView
DataKeyNames
=
"Id"
DataSourceID
=
"EntityAttachmentsDataSource"
>
<
Columns
>
<
telerik:GridBoundColumn
DataField
=
"Id"
DataType
=
"System.Int32"
HeaderText
=
"Id"
ReadOnly
=
"True"
UniqueName
=
"Id"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"FileName"
HeaderText
=
"FileName"
UniqueName
=
"FileName"
ReadOnly
=
"true"
DataType
=
"System.String"
>
</
telerik:GridBoundColumn
>
<
telerik:GridAttachmentColumn
DataSourceID
=
"EntityAttachmentDataSource"
MaxFileSize
=
"1048576"
EditFormHeaderTextFormat
=
"Upload Attachment:"
HeaderText
=
"Attachment"
HeaderTooltip
=
"Download Entity Attachment"
AttachmentDataField
=
"Attachment"
AttachmentKeyFields
=
"Id"
FileNameTextField
=
"FileName"
DataTextField
=
"FileName"
UniqueName
=
"InfringmentAttachment"
>
</
telerik:GridAttachmentColumn
>
</
Columns
>
</
MasterTableView
>
<
ClientSettings
>
<
ClientEvents
OnCommand
=
"GridOnCommand"
/>
</
ClientSettings
>
</
telerik:RadGrid
>
<
asp:EntityDataSource
ConnectionString
=
"name=MyEntities"
DefaultContainerName
=
"MyEntities"
EnableFlattening
=
"False"
EntitySetName
=
"EntityAttachments"
EntityTypeFilter
=
"EntityAttachment"
ID
=
"EntityAttachmentsDataSource"
runat
=
"server"
>
</
asp:EntityDataSource
>
<
asp:EntityDataSource
ConnectionString
=
"name=MyEntities"
DefaultContainerName
=
"MyEntities"
EnableFlattening
=
"False"
EntitySetName
=
"EntityAttachments"
EntityTypeFilter
=
"EntityAttachment"
ID
=
"EntityAttachmentDataSource"
runat
=
"server"
Where
=
"it.[Id] = @Id"
Select
=
"it.[Attachment]"
>
<
SelectParameters
>
<
asp:Parameter
Name
=
"Id"
Type
=
"Int32"
/>
</
SelectParameters
>
</
asp:EntityDataSource
>
I disabled ajax fine (ConditionalPostback, etc.) and can upload no worries. But I can't get the attachment to download direct from the datasource. All the examples I can find are for SqlDataSource.
Richard
When a parent record is expanded I want to evaluate and either show or hide the AddNewRecordButton on the multiple detail tables . I found that I can turn it off in the ItemDataBound event with this code. Which appears to work until the grid rebinds and then it applies to all records universally. I think I am coming at this from the wrong direction. Is there a better way?
GridDataItem item = (GridDataItem)e.Item;
if
(_currentDate < DateTime.Today && _currentDate !=
null
)
{
((RadGrid)(item.Parent.Parent.Parent)).MasterTableView.DetailTables[0].CommandItemDisplay = Telerik.Web.UI.GridCommandItemDisplay.None;
((RadGrid)(item.Parent.Parent.Parent)).MasterTableView.DetailTables[1].CommandItemDisplay = Telerik.Web.UI.GridCommandItemDisplay.None;
((RadGrid)(item.Parent.Parent.Parent)).MasterTableView.DetailTables[2].CommandItemDisplay = Telerik.Web.UI.GridCommandItemDisplay.None;
}
<
telerik:RadEditor
ID
=
"txtEmailBody"
runat
=
"server"
Width
=
"750px"
StripFormattingOptions
=
"MSWord, Css, Span, ConvertWordLists"
EditModes
=
"All"
StripFormattingOnPaste
=
"MSWord, Css, Span, ConvertWordLists"
ToolsFile
=
"~/DesktopModules/Test/RadEditorTools.xml"
>
</
telerik:RadEditor
>
HI,
excuse for my english am french
i start to build my new back office manager with your solution.
they start to develop in dotnet (transfer to asp 3.0)
i build an news manager with
datagrid / insert-update-delete with usercontrol ( in datagrid)
my news manager use 2 racontrols : editor (they work fine !!!) and radupload for litle image of the news all page are in masterpage :
In actu.aspx they have one raddatagrid they call webusercontrol.ascx
In webusercontrolascx they have radeditor and radupload.
this code work when they run in single page (not include in master page)
In masterpage the radeditor work well but the radupload return nothing I thinks i can’t find this control.
Protected Sub RadGrid1_UpdateCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles RadGrid1.UpdateCommand
'Get the GridEditableItem of the RadGrid
Dim editedItem As GridEditableItem = TryCast(e.Item, GridEditableItem)
Dim MyUserControl As UserControl = CType(e.Item.FindControl(GridEditFormItem.EditFormUserControlID), UserControl)
'InitializeUpdateParameter(DirectCast(e.Item.FindControl("RadUpload1"), RadUpload))
'Get the primary key value using the DataKeyValue.
Dim actuID As String = editedItem.OwnerTableView.DataKeyValues(editedItem.ItemIndex)("ID").ToString()
'Access the textbox from the edit form template and store the values in string variables.
Dim Titre As String = CType(MyUserControl.FindControl("titre"), TextBox).Text
Dim Description As String = CType(MyUserControl.FindControl("RadEditor1"), RadEditor).Content
'Dim RadUpload1 As RadUpload = TryCast(e.Item.FindControl("RadUpload1"), RadUpload)
Dim RadUpload1 As RadUpload = CType(MyUserControl.FindControl("RadUpload1"), RadUpload)
Dim Imageup As String
If RadUpload1.UploadedFiles.Count > 0 Then
System.Threading.Thread.Sleep(3000)
End If
For Each f As UploadedFile In RadUpload1.UploadedFiles
If f.FileName <> "" Then
Imageup = f.GetName
Else
Imageup = "none"
'Dim imaup As String =
'Open the SqlConnection
End If
Next
Try
SqlConnection.Open()
'Update Query to update the Datatable
Dim updateQuery As String = "UPDATE Actuvdotnet set TitreNews='" & Titre & "',Description='" & Description & "',Image='" & Imageup & "' where ID='" & actuID & "'"
SqlCommand.CommandText = updateQuery
SqlCommand.Connection = SqlConnection
SqlCommand.ExecuteNonQuery()
'Close the SqlConnection
SqlConnection.Close()
Catch ex As Exception
RadGrid1.Controls.Add(New LiteralControl("Impossible de mettre à jour la base de donnée : " + ex.Message))
e.Canceled = True
End Try
End Sub
In master page the radeditor work well but the radupload return nothing I thinks i can find this control
Can you help me please.
<
EditFormSettings
CaptionFormatString
=
"Mise à jour de la fiche : {0}"
ColumnNumber
=
"2"
InsertCaption
=
"Nouveau Compte"
CaptionDataField
=
"DenominationClient"
EditColumn-HeaderText
=
""
EditColumn-ButtonType
=
"PushButton"
EditColumn-CancelText
=
"Annuler"
EditColumn-InsertText
=
"Ajouter"
EditColumn-UpdateText
=
"Valider"
FormCaptionStyle-Font-Bold
=
"true"
PopUpSettings-Modal
=
"true"
EditColumn-ItemStyle-Font-Bold
=
"true"
FormTableItemStyle-Font-Bold
=
"true"
FormTableAlternatingItemStyle-Font-Bold
=
"true"
FormTableAlternatingItemStyle-VerticalAlign
=
"Middle"
FormTableItemStyle-VerticalAlign
=
"Middle"
FormTableItemStyle-HorizontalAlign
=
"left"
FormTableAlternatingItemStyle-HorizontalAlign
=
"left"
FormTableStyle-HorizontalAlign
=
"left"
PopUpSettings-ShowCaptionInEditForm
=
"true"
EditColumn-SortedBackColor
=
"ActiveBorder"
>
<
telerik:RadSplitter ID="RadSplitter1" Runat="server" Height="100%"
PanesBorderSize="3" Skin="Sunset" SplitBarsSize="8px" Width="100%">
<telerik:RadPane ID="RadPane1" Runat="server">
<telerik:RadSlidingZone ID="RadSlidingZone1" Runat="server">
<telerik:RadSlidingPane ID="RadSlidingPane1" Runat="server" Title="Load Yahoo" TabView="TextAndImage" OnClientExpanding="OnYahooExpanding" EnableDock="true"
CollapseText="Yahoo">
</telerik:RadSlidingPane>
<telerik:RadSlidingPane ID="RadSlidingPane2" Runat="server" Title="Load Google" TabView="TextAndImage" OnClientExpanding="OnGoogleExpanding" EnableDock="true"
CollapseText="Google">
</telerik:RadSlidingPane>
</telerik:RadSlidingZone>
</telerik:RadPane>
<telerik:RadSplitBar ID="RadSplitBar1" runat="server">
</telerik:RadSplitBar>
<telerik:RadPane ID="RadPane2" runat="server">
<uc1:WebUserControl ID="WebUserControl1" runat="server" />
</telerik:RadPane>
</telerik:RadSplitter>
Here is javascript code
<
telerik:RadScriptBlock ID="scriptBlock" runat="server">
<script type="text/javascript">
function OnYahooExpanding(sender, args) {
viewYahoo();
}
function OnGoogleExpanding(sender, args) {
viewGoogle();
}
function viewYahoo() {
var splitter = $find("<%=RadSplitter1.ClientID %>");
var pane = splitter.getPaneById("<%=RadPane1.ClientID %>");
if (!pane) return;
pane.set_contentUrl(
'http://www.yahoo.com');
pane.expand();
}
function viewGoogle() {
var splitter = $find("<%=RadSplitter1.ClientID %>");
var pane = splitter.getPaneById("<%=RadPane1.ClientID %>");
if (!pane) return;
pane.set_contentUrl(
'http://www.google.com');
pane.expand();
}
</script>