RadGrid w TableViews erases RadUpload Data

Thread is closed for posting
2 posts, 0 answers
  1. Mark Match
    Mark Match avatar
    16 posts
    Member since:
    Feb 2010

    Posted 16 Mar 2010 Link to this post

     

    The actual tool I am testing this on has 2 table views inside a rad grid.

    On the last level I added an upload file feature.  But when the click event happens the RadUpload no longer has a file.  Even though I selected a file.

    Here is what the aspx code looks like:
    <
    telerik:RadGrid ID="RadGrid1" ShowStatusBar="true" DataSourceID="ObjectDataSource1" runat="server" 

     

     

    AutoGenerateColumns="False" PageSize="7" AllowSorting="True" AllowMultiRowSelection="False"  

     

    AllowPaging="True" GridLines="None">

     

    <PagerStyle Mode="NumericPages"></PagerStyle>

     

    <MasterTableView DataSourceID="ObjectDataSource1"

     

    DataKeyNames="PONumber" AllowMultiColumnSorting="True">

     

    <DetailTables>

     

    <telerik:GridTableView DataKeyNames="PurchaseOrderItemId" AutoPostBack="True" AllowAutomaticUpdates="true"

     

    EditMode="InPlace" DataSourceID="ObjectDataSource2" Width="100%" runat="server">

     

    <ParentTableRelation>

     

    <telerik:GridRelationFields DetailKeyField="PONumber" MasterKeyField="PONumber" />

     

    </ParentTableRelation 

     

    <DetailTables>

     

    <Columns>

    <

     

    telerik:GridBoundColumn SortExpression="DocumentTypeName" HeaderText="Document Type Name"

     

     

    HeaderButtonType="TextButton" DataField="DocumentTypeName" UniqueName="DocumentTypeName">

     

     

    </telerik:GridBoundColumn>

     

     

    <telerik:GridTemplateColumn UniqueName="DocumentFileName" HeaderText="File Name"

     

    DataField="DocumentFileName">

     

     

    <ItemTemplate>

     

    <asp:HyperLink ID="hlFile" runat="server" Target="_blank" Text='<%# Bind("DocumentFileName") %>' /> 

     

     

    </ItemTemplate>

     

     

    </telerik:GridTemplateColumn>

     

     

    <telerik:GridTemplateColumn UniqueName="ReplaceFileName" HeaderText="Replace File"

     

     

    DataField="ReplaceFileName">

     

     

    <ItemTemplate>

     

     

    <telerik:RadUpload ID="FileUpload1" runat="server" MaxFileInputsCount="1" InitialFileInputsCount="1"

     

     

    ControlObjectsVisibility="None" />

     

     

    </ItemTemplate>

     

     

    </telerik:GridTemplateColumn>

     

     

    <telerik:GridTemplateColumn HeaderText="Save" HeaderButtonType="TextButton" UniqueName="Save">

     

     

    <ItemTemplate>

     

     

    <asp:Button ID="btnSave" runat="server" Text="Save" Width="80" ToolTip="Click here to save the new file."

     

     

    OnClick="btnSave_Click" UseSubmitBehavior="False" />

     

     

    </ItemTemplate>

     

     

    </telerik:GridTemplateColumn>
    </

     

    Columns>

     

     

    </telerik:GridTableView>

     

    </DetailTables>

     

    <Columns>

     

    <telerik:GridBoundColumn SortExpression="PONumber" HeaderText="PO Number" HeaderButtonType="TextButton"

     

    DataField="PONumber" UniqueName="PONumber">

     

    </telerik:GridBoundColumn>

     

    <telerik:GridBoundColumn SortExpression="CompanyName" HeaderText="Company Name" HeaderButtonType="TextButton"

     

     

    DataField="CompanyName" UniqueName="CompanyName">

     

    </telerik:GridBoundColumn>

     

    </Columns>

     

    </MasterTableView>

     

    <ClientSettings>

     

    <Selecting AllowRowSelect="true" />

     

    </ClientSettings>

     

    </telerik:RadGrid>

    Here is the save function in cs:

     

    protected

     

    void btnSave_Click(object sender, EventArgs e)

     

     

    {

     

     

    GridDataItem item = (GridDataItem)((Button)sender).Parent.Parent;  

     

    //PO Number works fine.
    int
    iPONumber = item.OwnerTableView.DataKeyValues[item.ItemIndex]["PONumber"] == DBNull.Value ? 0 : Convert.ToInt32(item.OwnerTableView.DataKeyValues[item.ItemIndex]["PONumber"]);

     

    string sDocumentTypeName = item.OwnerTableView.DataKeyValues[item.ItemIndex]["DocumentTypeName"].ToString();

     

    string sFileName = item.OwnerTableView.DataKeyValues[item.ItemIndex]["DocumentFileName"].ToString();

     

     

    //This code finds the RadUpload but it no longer has the attached files when the Save button is clicked.
    RadUpload
    RadUpload1 = item.FindControl("FileUpload1") as RadUpload;

     


    //This should have a count value of 1 for the 1 file I added.

     

     

     

    if (RadUpload1.UploadedFiles.Count == 0)

    {

    // skips out if there are no files  

     

     

     

     

    return;

    }
    //process the file if one exists.
    }

     

     

  2. Mark Match
    Mark Match avatar
    16 posts
    Member since:
    Feb 2010

    Posted 16 Mar 2010 Link to this post

    I added this to fix it:

    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">

                                                            <script type="text/javascript">
                                                                // <![CDATA[
                                                                //Disable ajax to perform upload actions
                                                                function conditionalPostback(sender, eventArgs) {
                                                                    var theRegexp = new RegExp("\.UpdateButton$|\.PerformInsertButton$|\.btnSave$", "ig");
                                                                    if (eventArgs.get_eventTarget().match(theRegexp)) {
                                                                        eventArgs.set_enableAjax(false);
                                                                    }
                                                                }
                                                                // ]]>
                                                            </script>
                                                        </telerik:RadCodeBlock>

    <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" ClientEvents-OnRequestStart="conditionalPostback">
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top