similar to radupload in radgrid demo

5 posts, 0 answers
  1. Greg
    Greg avatar
    9 posts
    Member since:
    Apr 2008

    Posted 21 Jun 2010 Link to this post

    I have something similar to the demo; however my code uses a Form Template to define the "editing" form fields...the demo doesn't.

    How can i leverage the demo code but reference a FormTemplate for RadUploading to a database?

    My code has this...
    <Columns> 
                    <telerik:GridBoundColumn DataField="ArticleID" DataType="System.Guid" HeaderText="ArticleID" 
                        ReadOnly="True" SortExpression="ArticleID" UniqueName="ArticleID" Visible="False" 
                        HeaderStyle-Wrap="False"
                        <HeaderStyle Wrap="False"></HeaderStyle> 
                    </telerik:GridBoundColumn> 
                    <telerik:GridTemplateColumn DataField="ArticleTitle" HeaderText="Article Title" UniqueName="ArticleTitle"
                        <ItemTemplate> 
                            <asp:HyperLink ID="hypArtID" Text='<%# Bind("ArticleTitle") %>' NavigateUrl='<%#"~/articles/article_view.aspx?ArticleID=" + DataBinder.Eval (Container.DataItem, "ArticleID") %>' 
                                runat="server"></asp:HyperLink> 
                        </ItemTemplate> 
                    </telerik:GridTemplateColumn> 
                    <telerik:GridBoundColumn DataField="ArticleSubject" HeaderText="Article Subject" 
                        SortExpression="ArticleSubject" UniqueName="ArticleSubject" HeaderStyle-Wrap="False" 
                        ItemStyle-VerticalAlign="Top" Visible="false"
                        <HeaderStyle Wrap="False"></HeaderStyle> 
                        <ItemStyle VerticalAlign="Top"></ItemStyle> 
                    </telerik:GridBoundColumn> 
                    <telerik:GridTemplateColumn DataField="ArticleContent" HeaderText="Article Content" 
                        SortExpression="ArticleContent" UniqueName="ArticleContent" ItemStyle-VerticalAlign="Top"
                        <ItemTemplate> 
                            <asp:Label ID="ArticleContentLabel" runat="server" Width="300px" Text='<%# Truncate(DataBinder.Eval (Container.DataItem, "ArticleContent")) %>'></asp:Label> 
                        </ItemTemplate> 
                        <ItemStyle VerticalAlign="Top"></ItemStyle> 
                    </telerik:GridTemplateColumn> 
                    <telerik:GridTemplateColumn DataField="ArticleDateTime" DataType="System.DateTime" 
                        HeaderText="Article Date" SortedBackColor="LightGray" SortExpression="ArticleDateTime" 
                        UniqueName="ArticleDateTime" ItemStyle-HorizontalAlign="Center" ItemStyle-VerticalAlign="Top"
                        <ItemTemplate> 
                            <asp:Label ID="ArticleDateTimeLabel" runat="server" Text='<%# Eval("ArticleDateTime","{0:d}") %>'></asp:Label> 
                        </ItemTemplate> 
                        <ItemStyle HorizontalAlign="Center" VerticalAlign="Top"></ItemStyle> 
                    </telerik:GridTemplateColumn> 
                    <telerik:GridBoundColumn DataField="ArticleExp" DataType="System.DateTime" HeaderText="ArticleExp" 
                        SortExpression="ArticleExp" UniqueName="ArticleExp" Visible="False" HeaderStyle-Wrap="False" 
                        ItemStyle-VerticalAlign="Top"
                        <HeaderStyle Wrap="False"></HeaderStyle> 
                        <ItemStyle VerticalAlign="Top"></ItemStyle> 
                    </telerik:GridBoundColumn> 
                    <telerik:GridCheckBoxColumn DataField="ArticleExpChkBox" DataType="System.Boolean" 
                        HeaderText="ArticleExpChkBox" SortExpression="ArticleExpChkBox" UniqueName="ArticleExpChkBox" 
                        Visible="False" HeaderStyle-Wrap="False" ItemStyle-VerticalAlign="Top"
                        <HeaderStyle Wrap="False"></HeaderStyle> 
                        <ItemStyle VerticalAlign="Top"></ItemStyle> 
                    </telerik:GridCheckBoxColumn> 
                    <telerik:GridTemplateColumn DataField="UserName" HeaderText="User Name" SortExpression="UserName" 
                        UniqueName="UserName" Visible="False"
                    </telerik:GridTemplateColumn> 
                    <telerik:GridBinaryImageColumn DataField="ArticleBillboardImage" HeaderText="Article Image" 
                        ImageAlign="NotSet" ResizeMode="Fit" ImageHeight="199px" ImageWidth="135px" DataAlternateTextFormatString="Image of {0}" 
                        DataAlternateTextField="ArticleBillboardImageDesc" UniqueName="ArticleBillboardImage" 
                        Visible="False"
                    </telerik:GridBinaryImageColumn> 
                    <telerik:GridTemplateColumn DataField="ArticleBillboardImageName" HeaderText="Article Image Name" 
                        UniqueName="ArticleBillboardImageName" Visible="False"
                        <ItemTemplate> 
                            <asp:Label runat="server" ID="lblArticleBillboardImageName" Text='<%# Eval("ArticleBillboardImageName") %>' /> 
                        </ItemTemplate> 
                    </telerik:GridTemplateColumn> 
                    <telerik:GridTemplateColumn DataField="ArticleBillboardImageDesc" HeaderText="Article Image Description" 
                        UniqueName="ArticleBillboardImageDesc" Visible="False"
                        <ItemTemplate> 
                            <asp:Label runat="server" ID="lblArticleBillboardImageDesc" Text='<%# Truncate(DataBinder.Eval (Container.DataItem, "ArticleBillboardImageDesc")) %>' /> 
                        </ItemTemplate> 
                    </telerik:GridTemplateColumn> 
                </Columns> 
                <EditFormSettings EditFormType="Template"
                    <FormTemplate> 
                        <table id="ArticleEditForm" width="100%"
                            <tr> 
                                <td style="padding-left: 5px"
                                    Article Title 
                                </td> 
                                <td align="left"
                                    <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("ArticleTitle", "{0}") %>' 
                                        Width="200px"></asp:TextBox> 
                                </td> 
                            </tr> 
                            <tr> 
                                <td style="padding-left: 5px"
                                    Article Subject 
                                </td> 
                                <td align="left"
                                    <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("ArticleSubject", "{0}") %>' 
                                        Width="200px"></asp:TextBox> 
                                </td> 
                            </tr> 
                            <tr> 
                                <td style="padding-left: 5px"
                                    Article Posted 
                                </td> 
                                <td align="left"
                                    <asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("ArticleDateTime") %>' ReadOnly="True"></asp:TextBox> 
                                </td> 
                            </tr> 
                            <tr> 
                                <td style="padding-left: 5px"
                                    Article Expiration 
                                </td> 
                                <td align="left"
                                    <telerik:RadDateTimePicker ID="RadDateTimePicker2" runat="server" Culture="English (United States)" 
                                        Skin="Default" DbSelectedDate='<%# Bind("ArticleExp", "{0:g}") %>'
                                        <TimePopupButton HoverImageUrl="" ImageUrl="" /> 
                                        <TimeView ID="TimeView2" runat="server" CellSpacing="-1"
                                        </TimeView> 
                                        <Calendar ID="Calendar2" runat="server" Skin="Hay" UseColumnHeadersAsSelectors="False" 
                                            UseRowHeadersAsSelectors="False" ViewSelectorText="x"
                                        </Calendar> 
                                        <DatePopupButton HoverImageUrl="" ImageUrl="" /> 
                                    </telerik:RadDateTimePicker> 
                                </td> 
                            </tr> 
                            <tr> 
                                <td style="padding-left: 5px"
                                    User Name 
                                </td> 
                                <td align="left"
                                    <asp:Label ID="Label5" runat="server" Text='<%# Bind("UserName") %>'></asp:Label> 
                                </td> 
                            </tr> 
                            <tr> 
                                <td style="padding-left: 5px"
                                    Article UserID 
                                </td> 
                                <td align="left"
                                    <asp:Label ID="Label3" runat="server" Text='<%# Bind("UserID", "{0}") %>'></asp:Label> 
                                </td> 
                            </tr> 
                            <tr> 
                                <td style="padding-left: 5px"
                                    Article Content 
                                </td> 
                                <td align="left"
                                    <telerik:RadEditor Width="99%" ID="RadEditor1" runat="server" Content='<%# Bind("ArticleContent") %>' 
                                        ToolbarMode="ShowOnFocus" EnableTheming="True" EnableResize="False" ToolsFile="~/admin/Tools/ToolsFile.xml"
                                        <Languages> 
                                            <telerik:SpellCheckerLanguage Code="en-US" Title="English" /> 
                                        </Languages> 
                                        <CssFiles> 
                                            <telerik:EditorCssFile Value="~/admin/Tools/CSS/EditorContentArea.css" /> 
                                        </CssFiles> 
                                        <Modules> 
                                            <telerik:EditorModule Name="RadEditorStatistics" Enabled="true" /> 
                                        </Modules> 
                                    </telerik:RadEditor> 
                                </td> 
                            </tr> 
                            <tr> 
                                <td style="padding-left: 5px"
                                    Article Image 
                                </td> 
                                <td align="left"
                                    <telerik:RadBinaryImage ID="RadBinaryImage1" DataValue='<%#Eval("ArticleBillboardImage") is DBNull ? null : Eval("ArticleBillboardImage")%>' Height="199px"  Width="135px" ToolTip='<%#Eval("ArticleBillboardImageDesc", "Photo of {0}") %>' 
                                    AlternateText='<%#Eval("ArticleBillboardImageDesc", "Photo of {0}") %>' runat="server" ResizeMode="Crop" /> 
                                     
                                </td> 
                                <td> 
                                    <telerik:RadProgressManager ID="RadProgressManager1" runat="server" /> 
                                 
                                </td> 
                            </tr> 
                            <tr> 
                            <td style="padding-left: 5px">Upload Image:</td> 
                            <td> 
                                <telerik:RadUpload ID="RadUpload1" runat="server" ControlObjectsVisibility="None" AllowedFileExtensions=".png, .jpg, .gif" MaxFileInputsCount="1" OverwriteExistingFiles="True"
                                </telerik:RadUpload><br /> 
                                <telerik:RadAsyncUpload ID="RadAsyncUpload1" ControlObjectsVisibility="None" AllowedFileExtensions=".png, .jpg, .gif" runat="server" MaxFileInputsCount="1" OverwriteExistingFiles="True"
                                </telerik:RadAsyncUpload> 
                                </td> 
     
                            </tr> 
                                                    <tr> 
                                <td style="padding-left: 5px"
                                    Article Image Name 
                                </td> 
                                <td align="left"
                                    <asp:TextBox ID="TextBox5" runat="server" Text='<%# Bind("ArticleBillboardImageName") %>'></asp:TextBox> 
                                </td> 
                            </tr> 
                                                    <tr> 
                                <td style="padding-left: 5px"
                                    Article Image Description 
                                </td> 
                                <td align="left"
                                    <asp:TextBox Rows="5"  MaxLength="500" ID="TextBox4"  
                                        Text='<%# Bind("ArticleBillboardImageDesc") %>' runat="server"  
                                        TextMode="MultiLine" Width="300px"></asp:TextBox> 
                                </td> 
                            </tr> 
                            <tr> 
                                <td class=""
                                    &nbsp; 
                                </td> 
                                <td align="right"
                                    &nbsp; 
                                </td> 
                            </tr> 
                            <tr> 
                                <td> 
                                    &nbsp; 
                                </td> 
                                <td align="right"
                                    <asp:Button ID="btnUpdate" runat="server" Text='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Update" %>' 
                                        CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>' /> 
                                    &nbsp; 
                                    <asp:Button ID="btnCancel" runat="server" CausesValidation="False" CommandName="Cancel" 
                                        Text="Cancel" /> 
                                </td> 
                            </tr> 
                        </table> 
                    </FormTemplate> 
    In the code i have listed...i was testing with both the RadUpload and the AsyncRadUpload...not sure would be a better fit.

    Also, i'm not sure if i need to include the logic from the demo for the postback issues?

    Thanks,
    Greg



  2. Genady Sergeev
    Admin
    Genady Sergeev avatar
    1600 posts

    Posted 24 Jun 2010 Link to this post

    Hi Greg,

    I have attached sample project to this replay that shows how to access RadUpload from codebehind when EditForm template is used. You can combine that with this demo. It shows  how to insert an image directly into a database. Keep in mind that this demo used the Q2 beta DLL.


    Greetings,
    Genady Sergeev
    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
  3. Bill
    Bill avatar
    26 posts
    Member since:
    Jun 2008

    Posted 07 Aug 2012 Link to this post

    This is a good demo but how do you display the image in the column from a file folder on the server path?
  4. Bill
    Bill avatar
    26 posts
    Member since:
    Jun 2008

    Posted 07 Aug 2012 Link to this post

    I tried to modify the code in the sample to:

    <telerik:GridImageColumn DataType="System.String" DataImageUrlFields="ImageID" DataImageUrlFormatString="Uploads/{0}.jpg"
                         AlternateText="Customer image" DataAlternateTextField="ImageName" ImageAlign="Middle"
                          ImageHeight="110px" ImageWidth="90px"
                          HeaderText="Image Column" FooterText="ImageColumn footer" />
    But it doesn't display the actual image?
    Where am I going wrong?
  5. Helen
    Admin
    Helen avatar
    1052 posts

    Posted 09 Aug 2012 Link to this post

    Hi,

    You may try to use RadBinaryImage like in the following demo:

    http://demos.telerik.com/aspnet-ajax/controls/examples/integration/gridandradasyncupload/defaultcs.aspx?product=upload


    Regards,
    Helen
    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
Back to Top