Click here to Skip to main content
15,906,947 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
XML
<asp:FormView ID="fvFileUpload" runat="server" Width="418px">
        <ItemTemplate>
            <asp:Label ID="lblFileId" Text="File ID" runat="server" Width="120px" />
            <asp:TextBox ID="txtFileID" runat="server" />
            <br />
            <asp:Label ID="lblFileName" Text="File Name" runat="server" Width="120px" />
            <asp:TextBox ID="txtFileName" runat="server" />
            <br />
            <asp:Label ID="lblFileKey" Text="File Key" runat="server" Width="120px" />
            <asp:TextBox ID="txtFileKey" runat="server" />
            <br />
            <asp:Label ID="lblUpload" Text="File Upload" runat="server" Width="120px" />
            <asp:FileUpload ID="fupload" runat="server" />
            <br />
            <asp:Label ID="lblUplodedBy" Text="File Owner" runat="server" Width="120px" />
            <asp:TextBox ID="txtOwner" runat="server" />
            <br />
            <br />
            <asp:Button ID="btnReq" Text="Requset to Auditor" runat="server" OnClick="btnReq_Click" />
            <asp:Button ID="btnClear" Text="Clear" runat="server" Height="25px" OnClick="btnClear_Click" Width="150px" />
        </ItemTemplate>
    </asp:FormView>



This is my code behind code

C#
private void FileIDGen()
   {
       string FileID = crudobj.SelectFileId();
       ((TextBox)fvFileUpload.FindControl("txtFileID")).Text = FileID; // im getting error here but im getting FileId string value as File1. the problem occurs when it tries to assign that value to the textbox
   }
Posted
Updated 12-Jul-14 2:55am
v2

"the problem occurs when it tries to assign that value to the textbox"
Because it can't find a control with the ID "txtFileID" as a child of the FormView - so it returns a null value.

Try the Page.FindControl method instead of the Control.FindControl, or use teh debugger to look at exactly what you have. We can;t solve this for you - we don't have any access to your code!
 
Share this answer
 
Try this.. :)

C#
TextBox txtproFileID = (TextBox)fvFileUpload.FindControl("txtFileID");
txtproFileID.Text=FileID;
 
Share this answer
 
v2

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


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