Advertisement

10.09.2008 at 08:52AM PDT, ID: 23801344
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.3

Autopopulating textboxes in Gridview using linqdatasource

Asked by abenage in Programming for ASP.NET, Microsoft Visual Basic.Net, Language Integrated Query - LINQ

Tags:

I have several gridviews working very well with a LinqDataSource.  I am able to Insert, Update and Delete records.

In the footertemplate of one of my grids, I have created a small form to insert a new record into the database, and that is working great.  The form consists of address related textboxes such as address, city, state and zip and none of the controls are bound to any data source.

What I would like to do is provide a way for the user to simply enter a zip code in the zip code text box and have the city and state textboxes populated from a table in the DB.  When the txtZipCode control looses focus, I would like to populate the city and state text boxes with a partial post back.  I have a script manager in my master page, and the webpart I am using is wrapped in an update panel.

I have several Linq data sources.  The GridView uses ldsPersonAddresses and there is a relationship to the postal_code table which contains the zip, city, and state.  I think I could use that datasource, but I don't know how to cause the postback and use txtZipCode.Text.  I also have a stored procedure available which would return the data...

How do I bind the txtCity and txtState controls with a partial postback?Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
<asp:LinqDataSource ID="ldsPersonAddresses" runat="server" ContextTypeName="VBCODE.jhadbDataClassesDataContext"
            TableName="person_addresses" Where="PersonID == @PersonID" EnableDelete="True"
            EnableInsert="True" EnableUpdate="True">
            <WhereParameters>
                <asp:QueryStringParameter Name="PersonID" QueryStringField="PersonID" Type="Int32" />
            </WhereParameters>
        </asp:LinqDataSource>
        <asp:LinqDataSource ID="ldsAddressTypes" ContextTypeName="VBCODE.jhadbDataClassesDataContext"
            TableName="address_types" runat="server">
        </asp:LinqDataSource>
        <asp:LinqDataSource ID="ldsStates" runat="server" ContextTypeName="VBCODE.jhadbDataClassesDataContext"
            TableName="states">
        </asp:LinqDataSource>
        <asp:LinqDataSource ID="ldsCountries" ContextTypeName="VBCODE.jhadbDataClassesDataContext"
            TableName="countries" runat="server">
        </asp:LinqDataSource>
        <asp:LinqDataSource ID="ldsZipCodeLookup" runat="server" 
            ContextTypeName="VBCODE.jhadbDataClassesDataContext" Select="new (City, State)" 
            TableName="postal_codes" Where="Zip == @Zip">
            <WhereParameters>
                <asp:FormParameter FormField="txtNewZip" Name="Zip" Type="String" />
            </WhereParameters>
        </asp:LinqDataSource>
[+][-]10.10.2008 at 12:44PM PDT, ID: 22690048

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Programming for ASP.NET, Microsoft Visual Basic.Net, Language Integrated Query - LINQ
Tags: ASP.NET 2.0, VB.NET
Sign Up Now!
Solution Provided By: novynov
Participating Experts: 1
Solution Grade: A
 
 
 
Loading Advertisement...
20081112-EE-VQP-44 / EE_QW_2_20070628