Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old March 12th, 2008, 06:54 AM
Authorized User
 
Join Date: Jun 2006
Location: , , .
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>



Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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 10: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



All times are GMT -4. The time now is 08:16 AM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.