Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
|
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 12th, 2008, 06:54 AM
Authorized User
 
Join Date: Jun 2006
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
Default Pull data values & assign them to a text control

When I click on the dropdown list, ddlTest the ddlTest_SelectedIndexChanged event executes:

CType(Me.GridView1.Rows(Me.GridView1.EditIndex).Fi ndControl("tbxTest"), TextBox).Text = "Newvalue"

The event will update the gridview text box tbxTest with with the value NEWVALUE. I would like to update the tbxTest with a value from the ddlTest data source SqlDataSource1 that matches the ID selected in the ddlTest. The gridview useses a different datasource, but the datasource has a field named test.

How do you modify the Protected Sub ddlTest_SelectedIndexChanged to pull from the SqlDataSource1 instead of inserting the value "NewValue? Please tell me what I am doing wrong?

 Existing Code

 <asp:TemplateField HeaderText="ID" SortExpression="Id">
                <EditItemTemplate>
                <asp:DropDownList ID="ddlTest" runat="server" AutoPostBack=true OnSelectedIndexChanged="ddlTest_SelectedIndexChang ed" DataSourceID="SqlDataSource1" DataTextField="Id" DataValueField="Id">
                 </asp:DropDownList>
             </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="lblFunctions" runat="server" Text='<%# Bind("ID") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>


<asp:TemplateField HeaderText="Test" SortExpression="Test">
                <EditItemTemplate>
                    &nbsp;<asp:TextBox ID="tbxTest" runat="server" Text='<%# Bind("Test") %>'></asp:TextBox>&nbsp;
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="lblTest" runat="server" Text='<%# Bind("Test") %>'></asp:Label>
                </ItemTemplate>
             </asp:TemplateField>

ddlTest SQLDataSource1:

<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:testConnectionString6 %>"
SelectCommand="SELECT tblHR.ID, [tblTest].[Name], [tblTest.[Test] FROM tblHR INNER JOIN [tbTest] ON tblCHR.ID = [tblTest].ID">
        </asp:SqlDataSource>








Similar Threads
Thread Thread Starter Forum Replies Last Post
assign numerical values to text ptrussell2009 Excel VBA 9 October 8th, 2017 04:38 AM
Trying to pull values from dynamic radiobuttons kwilliams ASP.NET 2.0 Professional 0 November 14th, 2008 11:54 AM
How to pull Month & Year from Date(dd/mm/yyyy) istcomnet Classic ASP Basics 2 April 22nd, 2008 06:22 PM
Pull and Assign XSLT Parameter from ASPX Doc kwilliams ASP.NET 2.0 Basics 0 October 20th, 2006 11:35 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.