Question : SQL Query Results into a TextBox

Hello all,

I'm trying to get a sqldatasource value to input into a textbox. How can this be achieved? This column contains terms and conditions, so it contains a large amount of text which is why I need it in the textbox.

1:
2:
3:
4:
5:
6:
7:
8:
9:
<asp:TextBox id="txtTerms" TextMode="multiline" Wrap="true" ReadOnly="true" Height="150px" Width="100%" ForeColor="GrayText" Font-Size="11px" runat="server"></asp:TextBox>

 <asp:SqlDataSource ID="SqlTerms"
                       runat="server"
                       ConnectionString="<%$ ConnectionStrings:Focus %>"
                       ProviderName="<%$ ConnectionStrings:Focus.ProviderName %>"
                       SelectCommand="SELECT TermsAndConditions FROM tblPPTermsAndConditions                        WHERE ID=1003">
    </asp:SqlDataSource>

Answer : SQL Query Results into a TextBox

Actually scratch that. What you need to do is manually invoke the Select method of the SqlDataSource object, which will return a DataView containing the query results:
1:
2:
System.Data.DataView view = (System.Data.DataView)SqlDataSource1.Select(DataSourceSelectArguments.Empty);
MyTextBox.Text = view[0][1].ToString();
Random Solutions  
 
programming4us programming4us