ASP.NET FormView - Default Insert Mode Fill Values in the Textboxes
<p>I am new to ASP.NET.</p>

<p>Basically, I have a FormView for Insert new record. This FormView is also taking a QueryString from the URL (Page.aspx?ProposedID=63). I have the QueryStringParameter to select a particular record based on the ID from QueryString (see the code).</p>

<p>What I like to do is fill all the values from SelectCommand to the textboxes when the page_load. </p>

<pre><code>    &lt;form id="form1" runat="server"&gt;

        &lt;asp:FormView ID="FormView1" DefaultMode="Insert" runat="server"
        datasourceid="dsApprovedCreateNew"
        allowpaging="true"
        datakeynames="ProposedID"
        emptydatatext="No record found."  
        &gt; 
            &lt;InsertItemTemplate&gt; 

            &lt;table class="FormDetail" width="95%" height="100%" align="center" class="FormDetail" &gt; 
            &lt;tr&gt;
                &lt;td class="right"&gt;MDF Name:&lt;/td&gt;
                &lt;td&gt;
                    &lt;asp:TextBox ID="MDFName" runat="server" Width="50%"  Text='&lt;%#Bind("MDFAmount") %&gt;' &gt; &lt;/asp:TextBox&gt;
                    &lt;asp:RequiredFieldValidator ID="RequiredFieldValidator1" ControlToValidate="MDFName" 
                    Text="The MDFName field is required!" runat="server" /&gt;

                &lt;/td&gt;
            &lt;/tr&gt;
                  &lt;uc:VendorListControl id="vendorListControl" runat="server" /&gt;
            &lt;tr&gt;
                &lt;td class="right"&gt;Vendor Quarter:&lt;/td&gt;
                &lt;td&gt;
                    &lt;asp:DropDownList ID="VendorQuarter" runat="server"
                    AppendDataBoundItems="true"&gt;
                        &lt;asp:ListItem Value="Q1"&gt;Q1&lt;/asp:ListItem&gt;
                        &lt;asp:ListItem Value="Q2"&gt;Q2&lt;/asp:ListItem&gt;
                        &lt;asp:ListItem Value="Q3"&gt;Q3&lt;/asp:ListItem&gt;
                        &lt;asp:ListItem Value="Q4"&gt;Q4&lt;/asp:ListItem&gt;
                 &lt;/asp:DropDownList&gt;
                &lt;/td&gt;
            &lt;/tr&gt;

            &lt;tr&gt;
                &lt;td class="right"&gt;MDF Amount:&lt;/td&gt;
                &lt;td&gt;
                    &lt;asp:TextBox ID="MDFAmount" runat="server" Width="20%" TextMode="SingleLine"&gt;&lt;/asp:TextBox&gt;
                    &lt;asp:CustomValidator ID="RangeValidator3" runat="server" ControlToValidate="MDFAmount" ErrorMessage="Enter numerical 
                    value only!"  ClientValidationFunction="validateNumber"/&gt;
                    &lt;asp:RequiredFieldValidator ControlToValidate="MDFAmount" Text="The MDFAmount field is required!" runat="server" /&gt;
                    &lt;%--
                    &lt;asp:RegularExpressionValidator ID="RangeValidator4" runat="server" ControlToValidate="MDFAmount" Display="Dynamic" 
                    ErrorMessage="*Enter numerical value only" ValidationExpression="^\d*[0-9](|.\d*[0-9]|,\d*[0-9])?$"/&gt;
                    --%&gt;
                &lt;/td&gt;
            &lt;/tr&gt;
            &lt;tr&gt;
                &lt;td class="right"&gt;Begin Date (mm/dd/yyyy):&lt;/td&gt;
                &lt;td&gt;
                    &lt;asp:TextBox ID="StartDate" runat="server" Width="50%" TextMode="SingleLine"&gt;&lt;/asp:TextBox&gt;
                    &lt;asp:RegularExpressionValidator  ID="RangeValidator1" 
                    runat="server" ControlToValidate="StartDate" ForeColor="Red"
                     ErrorMessage="Enter Valid Date in dd/mm/yyyy format." 
                     SetFocusOnError="True" Display="Dynamic" Type="Date"
                     ValidationExpression="^(0[1-9]|1[012])[-/.](0[1-9]|[12][0-9]|3[01])[-/.](19|20)\d\d$"&gt;
&lt;/asp:RegularExpressionValidator&gt;


                &lt;/td&gt;
            &lt;/tr&gt;
            &lt;tr&gt;
                &lt;td class="right"&gt;End Date (mm/dd/yyyy):&lt;/td&gt;
                &lt;td&gt;
                    &lt;asp:TextBox ID="EndDate" runat="server" Width="50%"&gt;&lt;/asp:TextBox&gt;
                    &lt;asp:RegularExpressionValidator  ID="RangeValidator2" 
                         runat="server" ControlToValidate="EndDate" ForeColor="Red"
                         ErrorMessage="Enter Valid Date in dd/mm/yyyy format."                       
                         SetFocusOnError="True" Display="Dynamic" Type="Date"
ValidationExpression="^(0[1-9]|1[012])[-/.](0[1-9]|[12][0-9]|3[01])[-/.](19|20)\d\d$"/&gt;
                &lt;/td&gt;
            &lt;/tr&gt;


            &lt;tr&gt;
                &lt;td class="right"&gt;MDF Summary:&lt;/td&gt;
                &lt;td&gt;
                    &lt;asp:TextBox ID="MDFSummary" TextMode="MultiLine" Width="50%" Height="100" runat="server"&gt;&lt;/asp:TextBox&gt;
                &lt;/td&gt;
            &lt;/tr&gt;
                        &lt;tr&gt;
                &lt;td class="right"&gt;Status:&lt;/td&gt;
                &lt;td&gt;
                    &lt;asp:DropDownList ID="Status" runat="server"
                    AppendDataBoundItems="true"&gt;
                        &lt;asp:ListItem&gt;Active&lt;/asp:ListItem&gt;
                        &lt;asp:ListItem&gt;Inactive&lt;/asp:ListItem&gt;
                 &lt;/asp:DropDownList&gt;
                &lt;/td&gt;
            &lt;/tr&gt;
            &lt;tr&gt;
              &lt;td colspan="2"&gt;
                &lt;asp:linkbutton id="InsertButton"
                  text="Insert"
                  commandname="Insert"
                  runat="server" /&gt;
                &lt;asp:linkbutton id="CancelButton"
                  text="Cancel"
                  commandname="Cancel"
                  runat="server" /&gt; 
              &lt;/td&gt;
            &lt;/tr&gt;          
        &lt;/table&gt;

    &lt;asp:HiddenField ID="CreatedBy" runat="server" value="44444"/&gt; 
    &lt;/InsertItemTemplate&gt;     
    &lt;/asp:FormView&gt;    

 &lt;asp:sqldatasource id="dsApprovedCreateNew"
        connectionstring="&lt;%$ ConnectionStrings:ConnectionString%&gt;" 
        SelectCommand="SELECT MDFName, MDFAmount
             , (SELECT VendorName FROM MDF_Vendor 
             WHERE VendorID = p.VendorID) AS VendorName
              , (SELECT VendorBUName FROM MDF_VendorBU 
              WHERE VendorBUID = p.VendorBUID) AS VendorBUName
              FROM dbo.MDF_Proposed p Where p.ProposedID = @ProposedID"
        InsertCommand = "INSERT INTO [MDF_Approved] ([VendorID], [VendorBUID], [MDFName], 
              [BeginDate], [EndDate], [CreatedBy]) 
              VALUES (@VendorID, @VendorBUID, @MDFName, @BeginDate, @EndDate, '1234') "

        runat="server"&gt;
        &lt;SelectParameters&gt;
                    &lt;asp:QueryStringParameter Name="ProposedID" QueryStringField="ProposedID"  runat="server" /&gt;
        &lt;/SelectParameters&gt;
 &lt;/asp:sqldatasource&gt;
 &lt;/form&gt;
</code></pre>

<p>I have tried this, but the textbox does not fill in any value.  I know the Query is correct.</p>

<pre><code>&lt;asp:TextBox ID="MDFName" runat="server" Width="50%"  Text='&lt;%#Bind("MDFName") %&gt;' &gt; &lt;/asp:TextBox&gt;
</code></pre>

<p>Please help.  Thanks in advance.</p>
