Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 336011
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T10:12:09+00:00 2026-05-12T10:12:09+00:00

I have a sqldatasource with a very simple select statement that should always return

  • 0

I have a sqldatasource with a very simple select statement that should always return one row. I have textboxes on a page that i want to fill with that data from the datasource. how could i do this for textboxes? If there is no data in the database then i want the textboxes to remain empty. How can I accomplish this?

<asp:Panel ID = "Panel2" runat="server" DefaultButton = "save" >
                        <fieldset style="width: 524px"><legend>Rouse InterChange Details</legend>
                        <asp:FormView runat="server" ID="MyFormView" DataSourceID="SqlDataSource3" DefaultMode="Edit">
                        <ItemTemplate >
                        <table>
                            <tr>
                                <td align="right">Interchange ID:</td>
                                <td align="left">
                                    <asp:TextBox ID="txtIntID" runat="server" size="1" MaxLength = "2" Text='<%# Bind("Interchange_Id") %>'></asp:TextBox>
                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator8" ValidationGroup = "rouse"  Display ="None" ControlToValidate = "txtIntID" runat="server" ErrorMessage="You Must Provide an Interchange ID."> </asp:RequiredFieldValidator>
                                             <ajaxToolkit:ValidatorCalloutExtender ID="ValidatorCalloutExtender11" TargetControlID="RequiredFieldValidator8" HighlightCssClass="validatorCalloutHighlight" runat="server">
                                             </ajaxToolkit:ValidatorCalloutExtender>
                                </td>
                            </tr>
                            <tr>
                                <td align="right">Sender ID:</td>
                                <td align="left">
                                    <asp:TextBox ID="txtsender" runat="server" MaxLength = "15" ></asp:TextBox>
                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator9" ValidationGroup = "rouse"  Display ="None" ControlToValidate = "txtsender" runat="server" ErrorMessage="You Must Provide a Sender ID."> </asp:RequiredFieldValidator>
                                     <ajaxToolkit:ValidatorCalloutExtender ID="vce12" TargetControlID="RequiredFieldValidator9" HighlightCssClass="validatorCalloutHighlight" runat="server">
                                     </ajaxToolkit:ValidatorCalloutExtender>
                                </td>
                            </tr>
                            <tr>
                                <td align="right">Interchange Standard ID:</td>
                                <td align="left">
                                    <asp:TextBox ID="ISI" runat="server" size="1" MaxLength = "1" ></asp:TextBox>
                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator10" ValidationGroup = "rouse"  Display ="None" ControlToValidate = "ISI" runat="server" ErrorMessage="You Must Provide an Interchange Standard ID."> </asp:RequiredFieldValidator>
                                     <ajaxToolkit:ValidatorCalloutExtender ID="ValidatorCalloutExtender12" TargetControlID="RequiredFieldValidator10" HighlightCssClass="validatorCalloutHighlight" runat="server">
                                     </ajaxToolkit:ValidatorCalloutExtender>
                                </td>
                            </tr>
                            <tr>
                                <td align="right">Version:</td>
                                <td align="left">
                                    <asp:TextBox ID="Verstxt" runat="server" size="5" MaxLength = "5" ></asp:TextBox>
                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator11" ValidationGroup = "rouse"  Display ="None" ControlToValidate = "Verstxt" runat="server" ErrorMessage="You Must Provide a Version."> </asp:RequiredFieldValidator>
                                     <ajaxToolkit:ValidatorCalloutExtender ID="ValidatorCalloutExtender13" TargetControlID="RequiredFieldValidator11" HighlightCssClass="validatorCalloutHighlight" runat="server">
                                     </ajaxToolkit:ValidatorCalloutExtender>
                                </td>
                            </tr>
                            <tr>
                                <td align="right">Functional ID:</td>
                                <td align="left">
                                    <asp:TextBox ID="FuncID" runat="server" size="1" MaxLength = "2" ></asp:TextBox>
                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator12" ValidationGroup = "rouse"  Display ="None" ControlToValidate = "FuncID" runat="server" ErrorMessage="You Must Provide a Functional ID."> </asp:RequiredFieldValidator>
                                     <ajaxToolkit:ValidatorCalloutExtender ID="ValidatorCalloutExtender14" TargetControlID="RequiredFieldValidator12" HighlightCssClass="validatorCalloutHighlight" runat="server">
                                     </ajaxToolkit:ValidatorCalloutExtender>
                                </td>
                            </tr>
                            <tr style="display:none">
                                <td align="right">Group Control #</td>
                                <td align="left">
                                    <asp:TextBox ID="txtGroupcontrol" runat="server" size="6" MaxLength = "9" ></asp:TextBox>

                                </td>
                            </tr>
                        </table>
                        </ItemTemplate>
                        </asp:FormView>
                        <asp:SqlDataSource ID="SqlDataSource3" runat="server" 
                        ConnectionString="connectionstring" 
                        SelectCommand="select * from table1 "></asp:SqlDataSource>
                        </fieldset></asp:Panel>   
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T10:12:09+00:00Added an answer on May 12, 2026 at 10:12 am

    You should consider using a FormView control to do this. Using the binding controls is much easier and cleaner than trying to cram all of your code into the code-behind of the page. I also feel that it makes the page much easier to maintain, since you don’t have all of the C#/VB code to manage as well.

    <asp:FormView runat="server" ID="MyFormView" DataSourceID="MySqlDataSource" DefaultMode="Edit">
        <EditItemTemplate>
            <table>
                <tr>
                    <td align="right">Interchange ID:</td>
                    <td align="left">
                        <asp:TextBox ID="txtIntID" runat="server" Text='<%# Bind("InterchangeID") %>' size="1" MaxLength = "2"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator8" ValidationGroup = "rouse"  Display ="None" ControlToValidate = "txtIntID" runat="server" ErrorMessage="You Must Provide an Interchange ID."></asp:RequiredFieldValidator>
                        <ajaxToolkit:ValidatorCalloutExtender ID="ValidatorCalloutExtender11" TargetControlID="RequiredFieldValidator8" HighlightCssClass="validatorCalloutHighlight" runat="server">                                             </ajaxToolkit:ValidatorCalloutExtender>
                    </td>
                </tr>
    
            <!-- rest of your table here -->
            </table>
        </EditItemTemplate>
    </asp:FormView>
    <asp:SqlDataSource runat="server" ID="MySqlDataSource" 
        SelectCommand="SELECT * FROM MyTable" ConnectionString="<%$ ConnectionStrings:MyConnectionString %>" >
    </asp:SqlDataSource>
    

    See these links for more information:

    • http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.formview.aspx
    • http://quickstarts.asp.net/QuickStartv20/aspnet/doc/ctrlref/data/formview.aspx
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 162k
  • Answers 162k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer All the I* interfaces are just that - interface definitions.… May 12, 2026 at 12:05 pm
  • Editorial Team
    Editorial Team added an answer as far as I know, torrent uses µTP, which is… May 12, 2026 at 12:05 pm
  • Editorial Team
    Editorial Team added an answer It doesn't work because the Request, which has already happened… May 12, 2026 at 12:05 pm

Related Questions

I have a sqldatasource connection in whose parameters, the insert parameter is set as
I have this situation where I have a SqlDatasource control and the select query
I have a GridView which I am populating by calling a method to return
I'm having a problem getting a simple ASP.NET webpage to display. The page contains
On my page I have a DropDownList which I populate with database values from

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.