Click here to Skip to main content
14,736,834 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
There is a Datagrid which binds images with their ID; while click on edit button i have disabled the image and enable a button. Now for that button click i want to show a ajax modalpopup where i want to bind file uploader control. Now the popup displays properly but after selecting image while submit the popup Ok button there is no file in the uploader control which i was selected.


Here is my code snippet
<asp:UpdatePanel ID="UpdatePanel1" UpdateMode="Conditional" runat="server">
    <Triggers>
        <asp:AsyncPostBackTrigger ControlID="dgnews" />
    </Triggers>
    <ContentTemplate>
    <asp:DataGrid ID="dgnews" runat="server" AutoGenerateColumns="false" 

                    oncancelcommand="dgnews_cancel" ondeletecommand="dgnews_delete" 

                    oneditcommand="dgnews_edit" onpageindexchanged="dgnews_PageIndexChanged" 

                    onupdatecommand="dgnews_update" Width="715px" AllowPaging="true" 

            AllowSorting="true" DataKeyField="res_id"  PageSize="10" 

            onitemdatabound="dgnews_ItemDataBound" >
                    <PagerStyle HorizontalAlign="Center" Mode="NumericPages" 

                         Position="TopAndBottom"/>
                    <columns>
                    <asp:BoundColumn DataField="res_id" Visible="false" HeaderText=""></asp:BoundColumn>
                            <asp:TemplateColumn HeaderText="Image">
                                <ItemTemplate>
                                    <ul style="padding-removed15px;">
                                       <a href="#"><img id="imgSmall" src='<%# DataBinder.Eval(Container, "DataItem.res_image") %>' alt="Gallery Image" width="50" height="50" /></a>
                                    </ul>                                            
                                </ItemTemplate>
                                <EditItemTemplate>
                                    <asp:Button ID="aaa" Text="Select Images" runat="server"/>
                                        <cc1:ModalPopupExtender BackgroundCssClass="modalBackground"

    CancelControlID="Button2"  runat="server" PopupControlID="picuploader" ID="ModalPopupExtender1"

    TargetControlID="aaa" />
    <asp:Panel ID="picuploader" runat="server" CssClass="modalPopup" DefaultButton="Button1" Style="display:none;">
    <asp:UpdatePanel ID="UpdatePanel2" runat="server">
    <Triggers>
    <asp:AsyncPostBackTrigger ControlID="Button1" />
    </Triggers>
    <ContentTemplate>
            <table>
            <tr>
                <td>
                    <asp:Image Width="50px" Height="50px" ID="Image1" runat="server" /></td>
                <td>
                    <asp:FileUpload ID="FileUpload1"  runat="server" /></td>
            </tr>
            <tr>
                <td>
                    <asp:Image Width="50px" Height="50px" ID="Image2" runat="server" /></td>
                <td>
                <asp:FileUpload ID="FileUpload2"   runat="server" /></td>
            </tr>
            <tr>
                <td>
                    <asp:Image ID="Image3" runat="server" Width="50px" Height="50px" /></td>
                <td>
                <asp:FileUpload ID="FileUpload3"   runat="server" /></td>
            </tr>
            <tr>
                <td>
                    <asp:Image ID="Image4" runat="server" Width="50px" Height="50px"/></td>
                <td>
                <asp:FileUpload ID="FileUpload4"  runat="server" /></td>
            </tr>
            <tr>
                <td></td>
                <td><asp:Button ID="Button1" runat="server" Text="ok" OnClick="UploadPic" />
                    <asp:Button ID="Button2" runat="server" Text="cancel" /></td>
            </tr>
            </table>
            </ContentTemplate>
            </asp:UpdatePanel>
        </asp:Panel>
                                </EditItemTemplate>
                            </asp:TemplateColumn >
                           
                <asp:EditCommandColumn CancelText="Cancel" EditText="Edit" HeaderText="Modify" UpdateText="Update"/>
                            <asp:ButtonColumn CommandName="Delete" Text="Delete" HeaderText="Remove"/>                                           
                </columns>
                    </asp:DataGrid>
    </ContentTemplate>
    </asp:UpdatePanel>
Posted
Updated 16-Aug-12 21:44pm
v7
Comments
   
And the question is..?
--SA

where did u place datagrid databinding code??
place databinding code in is not postback method of pageload
   
Comments
sahabiswarup 17-Aug-12 6:57am
   
I have a Datagrid control which displays Id, Image. When I am clicking on edit button a button is there and after click that i want to open a modal popup extender which will be assigned to a panel that contains a fileupload control, ok and cancel button.

The problem is when I press the ok button the button_click event I am not able to find the file inside the FileUpload control.
This laying of pretend AJAX controls ( a popup does not use AJAX ), often ends in strife. Try just showing a normal popup, or using jquery and fancybox to do it.
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900