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
| 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
Thread Tools Search this Thread 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">
                <asp:DropDownList ID="ddlTest" runat="server" AutoPostBack=true OnSelectedIndexChanged="ddlTest_SelectedIndexChang ed" DataSourceID="SqlDataSource1" DataTextField="Id" DataValueField="Id">
                    <asp:Label ID="lblFunctions" runat="server" Text='<%# Bind("ID") %>'></asp:Label>

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

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">

Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 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

All times are GMT -4. The time now is 10:44 AM.

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