Grdiview, 2 dropdownlist, how to change values in Dropdownlist with Ajax

 

Hi, 

first of all, I'm new to AJAX and searched a lot about my topic, but couldn't find anything. 

Let’s describe my situation: I'm writing a Web application to manage the work schedule of the staff. Basically I have a table filled with date, project, subproject, time and additional description.
All the data is stored in a mysql database. To show the data I use a Gridview, in this GridView I have two depended dorpdownlists (DDL). If the value of the first DDL changes the content of the second drop dwonlist need to be updated. (Each project has its own subprojects). The problem with this is, that every row has this independent dropdownlist. So if the changes will be made in one row only this one row needs to be updated.
Actually the whole page will be reloaded after changing the project. The amount of rows in the GridView varies.
So my  question is, if it is possible to use the Ajaxtoolkit to get a dataset / table with subproject  from the server and bind this dataset / table to the second dropdown list.

 Thanks a lot.

here is the source code of the GridView:

 

 

 <asp:GridView ID="testGrid" runat="server" AutoGenerateColumns="False" >
            <Columns>
                <asp:TemplateField>
                       <ItemTemplate>
                        <asp:Button ID="deleteButton" runat="server" OnClick="deleteRow" Text="delete" />
                        <asp:Button ID="insertButton" runat="server" OnClick="insertRow" Text="insert" />
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:BoundField DataField="JDatum" HeaderText="Datum" ></asp:BoundField>
                <asp:TemplateField HeaderText="Projektname">
                    <ItemTemplate>
                    <asp:DropDownList  ID="DDL_Projects" runat="server"  OnLoad="DDL_Subprojects_Onload" DataSource ='<%# BindSource("Projekt", "") %>'
                        BackColor="LightYellow" ForeColor="DarkRed" DataValueField="name" SelectedValue = <%# DataBinder.Eval(Container.DataItem, "ProjName")%> AppendDataBoundItems="false"
                        OnSelectedIndexChanged="DDL_Projets_SelectedIndexChanged" AutoPostBack="true">
                        <asp:ListItem Value="0">Please Select</asp:ListItem>
                        </asp:DropDownList >
                   </ItemTemplate>
                </asp:TemplateField>
               
       
                <asp:TemplateField HeaderText="Unterprojekt">
               
                    <ItemTemplate>
                    <asp:DropDownList  ID="DDL_Subprojects" runat="server" 
                        BackColor="LightYellow" ForeColor="DarkRed" DataValueField="name"  AppendDataBoundItems="false" >
                        <asp:ListItem Value="0">Please Select</asp:ListItem>
                        </asp:DropDownList >
                   </ItemTemplate>
               
                </asp:TemplateField>
            
                <asp:TemplateField HeaderText="Mehraufwand" >
                    <ItemTemplate>
                        <asp:TextBox EnableViewState="True" ID="mehraufwand" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.mehraufwand") %>'>
                        </asp:TextBox>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Arbeitszeit">
                    <ItemTemplate>
                        <asp:TextBox EnableViewState="True" ID="ArbZeit" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.ArbZeit") %>'>
                        </asp:TextBox>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="ProjektBeschreibung">
                    <ItemTemplate>
                        <asp:TextBox EnableViewState="True" ID="Beschreibung" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.Beschreibung") %>'>
                        </asp:TextBox>
                    </ItemTemplate>
                </asp:TemplateField>
               
            </Columns>
            
        </asp:GridView>
0
inderlein
10/7/2008 5:43:33 AM
asp.net.networking-webservices 2181 articles. 0 followers. Follow

1 Replies
1002 Views

Similar Articles

[PageSpeed] 53

Hi 
 
This is a duplicate post: http://forums.asp.net/t/1328487.aspx
 
Thanks.

 


Lance Zhang
Microsoft Online Community Support

Please remember to mark the replies as answers if they help and unmark them if they provide no help.
0
Lance
10/10/2008 6:03:42 AM
Reply:

Similar Artilces:

Change value of textbox based on value from dropdownlist using ajax?
Hello, I want to program an aspx form so that depending on what value you select from a dropdownlist, a textbox gets populated using ajax or javasciprt (client based) I did this already server-side by reading from an SQL data table, but it's annoying because of the page refresh, anyway to do the same thing using ajax or javascript? Look at my code below:   Many thanks ! :)   Sub ddllocations_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddllocations.SelectedIndexChanged Dim strconn As String Dim myConnection As New SqlConnection(strconn) ...

DropDownList to DropDownList
I want to take the selected value of DropDownListA and based on that value do a query to the database and populate DropDownListB. For example, DropDownListA contains Entity values. If the user selects entity101 then I call stored procedure where I pass in the entity value, run a select statement and get a list of properties associated with the entity name. I want to take that list and populate DropDownListB. Easy enough to do with ASP.NET using the AutoPostBack. Would be real nice to do this with Atlas. Is it possible? If so, how? Atlas control toolkit has cascading dropdowns-please downlo...

How to change the dropdownlist's value from database on selection of 1 st dropdownlist
Hi Friends, I have 2 dropdownlist. 1 for country and 1 for state. When i will select any coutary according to that all state related to that countary shoud change in dropdownlist. I have to fatch both dropdownlist's value from sqlserver database. And i also don't know how to make relationship to get all value in aspx page. so please also tell me what should i made in database means primary foreign key concept. I will be very thankful if you can send me code for that.    There will be 2 tables in the database, Country with country_id as primary key. Another table Stat...

DropDownList selected value determines value of second DropDownList
I have a quick question that I'm sure has been addressed before, but I can't seem to find a solution. I have two drop down list fields: startTime and endTime coded as such: <asp:DropDownList id="startTime" runat="server"> <asp:ListItem Value="00:00">12:00 A.M.</asp:ListItem> <asp:ListItem Value="00:30">12:30 A.M.</asp:ListItem> <asp:ListItem Value="01:00">1:00 A.M.</asp:ListItem> <asp:ListItem Value="...

VB.NET
I have a DataGrid (see code at end of my question) with several dropdownlist controls within TemplateColumns for Editing.  For the first 2 ddls in my grid, ddlMedType and ddlMedicationName, I would like to populate ddlMedicationName based on the selecteditem of ddlMedType, but I don't know how to reference this. Thank you for saving me from confusion!!!! Here is my DataGrid code: NOTE: I've bolded the 2 controls that I need help with -- the rest you can really ignore!! ================== <asp:datagrid id="dgMeds" runat="server" OnEditCommand="dgMeds_EditRow" OnUpdateComm...

Changing textbox.Text value when dropdownlist changes
I figure this should be really simple. Here's what I want to happen: Page loads first time, textbox is blank. User changes dropdownlist to a certain value. Page refreshes and changes textbox.text to dropdownlist.SelectedItem.Value but keeps the value of any other textboxes that might've been changed by the user. I can make this work fine when it's just dynamic (non asp.net generated) text in the page. Thanks. hello, there is the OnSelectedIndexChanged which you should define,in that method you set the value of the textbox as follows: txt1.Text = ddl.SelectedItem.Value; ...

Change value of textbox dependent on value from dropdownlist
How do you achieve this but client-side, to avoid the constant page refresh? (Javascript)   Best, Asaf. You need to use an onChange event on your DropDownList and wire it to a JavaScript function. In the code example below, ddlID and txtID are the control IDs of your DropDownList and TextBox controls. Code: ddlID.Attributes.Add("onChange", "setText('" + ddlID.ClientID + "', '" + txtID.ClientID + "');"); JavaScript: function setText(ddl, txt){   var ddlID = document.getElementById(ddl);   var txtID = document.getElementById(txt);   &...

2 DropDownLists as criteria for third DropDownList
Here's what I need to do:User to select one item from each of two DDL's, and once that has been done, these items are used as parameters for retrieving relevant data (via stored procedure) from the database, the results of which are then displayed in a third DDL. I'm sure that what I want to do has been covered in some online tutorial somewhere. Please provide URL if you know where I can find it. Thanks!groggy froggy Hello,All what you have to do is the SELECT criteriaSELECT columnname FROM table1 WHERE col1 =" & ddl1.selectedvalue & " and col2 =" & ddl2.sel...

DropDownList changing another DropDownList Control
I am trying to get a DropDownList control to change immediately when another DropDownList selects a value. For instance I have a table which stores complaints. This table only has one field, that being TypeOfComplaint. I have another table which stores the ComplaintSubType, this table also has the TypeOfComplaint field. So I would like a DropDownList which is populated from the ComplaintTypes table and another DropDownList which populates from the ComplainSubType table according to what is selected in the first DropDownList. Does that make sense? I have no idea how to go about this! ...

How Select one dropdownlist value using down arrows corresponding other dropdownlist value are select
I am using two dropdownlist box.One is used for country selection. other one is used for state selection.I am using dropdown selectedindexchanged event. when i click country dropdownlist corresponding state is selected in state dropdownlist box. How select the country in country dropdownlist using down arrow keys at the same time corresponding state is select in state dropdown list.R.Karthikeyan   kartmca: How select the country in country dropdownlist using down arrow keys at the same time corresponding state is select in state dropdown list.Generally, we don't implmenet...

Text value not changing when new value on DropDownList selected
Hi, I am looking for assistance on how to correctly post events when a new item is selected on a drop down list. My drop down list has autopostback enabled and a sub routine associated with SelectedIndexChanged. This routine is activated when another entry in the drop down list is selected, however, the value is not changed and the drop down list returns to the originally selected value. For example, if I have 2 values in my drop down list, 0 and 1, and 0 is the currently selected value. Selecting 1 will trigger the event but the drop down list will return to displaying 0 as the selected ...

dropdownlist value not changing
hi, i have this in my aspx: <asp:dropdownlist id="activityList" runat="server" CssClass="standard-text" ></asp:dropdownlist> why is it this value always 1, even though i have changed it in the ui? Convert.ToInt32(activityList.SelectedItem.Value) thx i think you also need to use page.ispostback property? check for the page.IsPostback property and if true, DONT refill the dropdown.Mike Banavige~~~~~~~~~~~~Need a site code sample in a different language? Try converting it with: http://converter.telerik.com/...

2 DropDownList and Ajax
Hi there i have the following problem. I will fill values to a DropDownlist2 in dependence of DropDownlist1 . Everything without reload the whole page.I have already done a view on the CascadingDropDown Demo in the Ajax Toolkit. But it is hard to understand. Is there a solution with a database ?And could it be that the sample not works under visual studio 2005 ?   Hi, can you also show the parts of the code that didn't work? Did you install the control toolkit for ASP.NET AJAX 1.0 because it seems a bit hard to find for people as you can't directly download them from the cod...

DropDownList Value #2
Edited by SomeNewKid. Please post code between <code> and </code> tags. Hi, I'm populating a dropdownlist Control from the pubs database. When I try to retrieve the value of the selected item, I always get the first item in the list. Not sure what I'm doing wrong. I'm displaying the value in a label once the button is clicked. This is the code I have: <%@ Page Language="VB" %> <script runat="server"> Function ALLPublishers() As System.Data.IDataReader Dim connectionString As String = "server='(loc...

Web resources about - Grdiview, 2 dropdownlist, how to change values in Dropdownlist with Ajax - asp.net.networking-webservices

Tag Synonyms - Stack Overflow
Q&A for professional and enthusiast programmers

Accidental entities - what about the UI?
This post is a follow-up to my previous blog post " Accidental entities - you don't need that identity ". In that post, we followed a consultant ...

Flash Builder Plug-in for SAP Netweaver Gateway - Adobe Labs
Search Navigation Labs Home Wiki Home Technologies Alchemy Blueprint Camera Profiles and DNG Profile Editor Cirrus ColdFusion 10 DNG Codec Fireworks ...

Air Astana - Join Now
Thank you for considering membership of Nomad Club – Kazakhstan’s first Frequent Flyer Program. You could soon be on your way to earning free ...

Languages -> C# Articles, Tutorials, Examples: ASP Alliance
.NET,ASP,ASP.NET,SQL,XML,HTML,ADO,ADO.NET,JavaScript,JScript,CSharp,VBScript and VB tutorials from AspAlliance.

Blog - Avisra
Avisra Web Development Home Blog Services Contact The Blog Latest Module Builder: How can we make it better? Sitefinity by Chris on July 2, 2013 ...

Online Booking Tool Support
This Online Booking Tool Support page might help you as you navigate through the process of booking travel through your OBT provided by CWT. ...

@Html and beyond
... ); } return string .Format( “{0}{1}” , me.Member.Name, id); } The Html building methods are quite simple. Building a dropdownlist for a ...

Top Ranked Articles
Top Ranked Articles - Free source code and tutorials for Software developers and Architects.; Updated: 23 Feb 2013

Unit Testing DateTime.Now Without Isolation
public virtual void SeedWithYearsSince(DropDownList list, int year){ for (int index = year; index

Resources last updated: 12/22/2015 10:39:05 PM