Not able to select value from dropdownlist control

I used sql server database with the multiple table connectivity.  I created view to join three table and created stored procedure to fill dropdownlist control. I filled dropdownlist control succesfully but I am not able to select value from dropdownlist either by selectedItem.value or selectedItem.text. It selects first value only.

<asp:TableCell VerticalAlign="Top">
<asp:DropDownList ID="NewDistNameNo" Runat="server" Width="100%" DataTextField="dist_name_no" DataValueField="office_id" AutoPostBack="True" CssClass="TextBox" />

Codebehind is given below

Dim DistNo As Integer = cInt(NewDistNameNo.SelectedItem.Text)

Here is the view and Stored Procedure.
CREATE VIEW v_office_towndist
SELECT distinct,,,,
FROM office
left outer join district on
office.dist_id = district.dist_id
LEFT OUTER JOIN town_dist on
district.dist_id = town_dist.dist_id
@office_id int
SELECT distinct office_id, dist_id, dist_name_no from v_office_towndist
where v_office_towndist.office_id = @office_id order by dist_name_no asc
Please help me. Dead line of my project is very near. Please help me.
Thank you.
2/25/2005 5:43:00 PM 72751 articles. 3 followers. Follow

3 Replies

Similar Articles

[PageSpeed] 3

are you biinding the dropdownlist within If not ispostback loop in page_load ? that could be why you are losing your selections.
Dinakar Nethi
Life is short. Enjoy it.
2/25/2005 6:07:11 PM
Actually binding of data for dropdownlist occurs in OnIndexChanged event of onther dropdownlist controls. I know that its a probleb with autopostback property of dropdownlist, when I use autopostback=false it selects different value but it fetches first value only while inserting into table. 

I really appreciate for your reply, but please give some more advice and possibilities of my problem.
Thank you very much.
2/25/2005 6:51:51 PM
Actually binding of data for dropdownlist occurs in OnIndexChanged event of onther dropdownlist controls. I know that its a probleb with autopostback property of dropdownlist, when I use autopostback=false it selects different value but it fetches first value only while inserting into table. 

I really appreciate for your reply, but please give some more advice and possibilities of my problem.
Thank you very much.
2/25/2005 8:16:54 PM

Similar Artilces:

when loading a previously created record on to form, some controls are missing values(controls are depended on values selected in other controls)
Hello - I have created a page for Editing records.  this page will open up a chosen record and allow user to edit the data.On the form, I have 3 drop down lists.   The second dropdown list should fill values depending on value chosen in first dropdown list.  The third dropdown list should show/fill values depending on value chosen in second dropdown list.So taking this into count, i have several records with various data.  When I open-up/load a record in Edit form, only the first dropdown list has a value selected that was the pre-existing va...

how can i Fill the controls on web page by selecting value from dropdownlist control.
  Hi,  Currentlly i am working on a web application where i require to fill the web form with the selected item in a text box. for example i have dropdown control named supplier_name, and i want to fill all the other controls values from database on the form when i select name from that supplier_name box,i.e , if i select name1, then related to that name, its code,address ,city should appear on related text boxes. I have done the same in windows application with c# , but the problem with web application( is that, when i select Supplier _ it...

Problem in Using DropDownList Control to select a selected row of SqlDataSource that is under GridView Control
Hi all,In my SQL Server Management Studio Express, I have a database "ChemDatabase" that has a table "LabData"  formatted in the following way: SampleID int PRIMARY KEY, SampleName nvarchar(25), ChemicalName, nvarchar(25), Concentration decimal(6.2) with 5 rows of records in this .dbo table. In my Visual Web Developer Express, I created a website "RPD-TCE" for extracting a row of record from the LabData table by using a DropDownList, a GridView and a SqlDataSource.  I want to click DropDownList to list one number of S...

Control.Value and Control.SelectedItem.Value
Can someone explain to me the difference between say, Dropdownlist.SelectedItem.Value and Dropdownlist.SelectedValue?? Just curious, Thanks!Tim These are going to return the same thing. dropdownlist.selectedvalue is a shortcut to get the currently selected value in the dropdown. If that is all you want then you can just use that. If you want to access the currently selected item you can use dropdownlist.selecteditem and that return the item and you can then access any of the item's properties, including in this case the value property. If this post answered your question please r...

Select dropdownlist control value
Hi, I have created a dropdownlist dynamically and populated it with numbers from 1 to 10. I also have a submit button on my page which when clicked is supposed to get the number I have selected in my dropdownlist. But this does not happen. It keeps returning 1 even if I select 4. I'm guessing whenever the page is loaded the dropdownlist is being created again and hence it selects the first number which is 1. Can anyone tell me how to solve this problem? How do I get the value of the number I have selected from a dropdownlist which is created dynamically? Thanks in advance for ...

Not able to assing values when controls inside Tab control
Hi I am having a TabContainer and 4 tabs, inside each tab i have a update pannel and a gridview, the grid has an select command text, and some other coloumns. i have 2 text box out side the tabcontainer. so that the user selects an row in grid, the selected row's is displayed in the text box exg the grid has select   aaa    12     15105719    abc2 select   bbb    62     15342349    abc3 select   ccc    52   &nbs...

disable textbox control and dropdownlist control when selecting one of the radiobuttons
I want to disable the textbox control (also change its background colour) and dropdownlist control when I select one of the radiobuttons.I did it on the checkedchanged event of that radio button but it is not working.what should I do ?  Make the AutoPostBack property of radiobuttons trueIf this post was useful to you, please mark it as answer.ClientSideAsp.Net | Blog  Make sure you set the "AtuoPostBack" property for radiobuttonList to true then you can handle its selectedIndexChanged   Protected Sub RadioButtonList1_SelectedIndexChanged(By...

how to populate a dropdownlist control and update the selected item in a gridview control
Hi friends help me with this ... Requirement: 1) i want to populate a dropdownlist(ddl) in a gridview when clicking the edit button of a perticular row by using gridview events and also update the selected item of the ddl to the database. 2) also i don't want to use sqldatasource controls i.e. we should take the help of only gridview events 3) DropDownList will be populated fom TableB: Actions taken: In page_load while binding the grid i m getting the error: Cannot perform '=' operation on System.Int32 and System.String  my fields and datatypes are as follows...

Option to have no value selected in DropDownList control?
Whenever I DataBind a DropDownList, the list is already defaulted to a default value. I would like to user to have the option of not choosing anything from the dropdown list. The first line of the dropdown should be "-- Select --" or something similar. How can I accomplish this? When the user submits the form, no value should be passed for that input... I just can't get this to work at all. after binding the records from your database into your dropdownlist, add this code: DropDownList1.Items.Insert(0, "-- Select --") DropDownList1.SelectedIndex = 0 mes...

assign data to other controls after select value from dropdownlist
Hello, In the webform, there is one dropdownlist and some text boxes. what i want to do is: once i select one of value from the list, for exsample, employee name, then, his profile, like date of birth, address, phone .. will show in other textbox, my question is, which dropdownlist event i should us? how to assign data to the controls? I am new to ASP. Thank for help in advance. You will have to handle SelectedIndexChanged event and do your save there. Just double click on it in your webform and it will create the event.Sonu Kapoor [MVP] Feel free to ask me any .NET question | Ajax Data Co...

Catching multiple Control values on Dropdownlist selection
Hi to all, I've a problem... this is the situation: In a Datagrid I have a column reporting an ID in a control Label <asp:TemplateColumn Visible="False"> <HeaderStyle HorizontalAlign="Left"></HeaderStyle> <ItemTemplate> <asp:Label id="lblID" runat="server" EnableViewState="True" Visible="False" > <%# DataBinder.Eval(Container.DataItem, "ID") %> </asp:Label> </ItemTemplate> &l...

binding selected value to dropdownlist in repeater control
I am trying to bind the SelectedValue of a dropdownlist in an itemtemplate of a repeater control.  The problem is that some of the values I'm binding to are not in the dropdownlist.  I want to say if the field I'm binding to is not in the list, don't bind and just select the first item as usual, otherwise bind.  Where and how would i say that.  I've tried binding using <%#Bind()%> and that doesn't look like it's going to work.  Thanks for all your help. Dear, friend: Would you plz dump some codes here?  Best Regards,____________________________________...

Selected Value of DropDownList within a wizard control
Hello: Within the wizard there is a ddl that when a certain value is selected an action will be performed. I have read at least 50 posts by others with similar difficulties, but none with solutions that work for me. here is what I have so far:     protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)    {         UserControl objCtrl = ((UserControl)(FindControl("Wizard1")));        DropDownList ddl = ((DropDownList) (objCtrl.FindControl("DropDownList1")));  &n...

User Control DropDownList Selected Value Not Passed
Edited by SomeNewKid. Please post code between <code> and </code> tags. Hi, I'm using C#. I have a user control DropDownList (SearchCategory.ascx) that when included on my page (index.aspx) will not pass the selected value to a simple function in script tags of head content on a button click. It just passes the first value of the list no matter what is selected. I need to pass to the function (in the script tags of head content of index.aspx) the value of a text box (works fine cause it is not a user control) and the value of the DropDownList (only passes the first...

Web resources about - Not able to select value from dropdownlist control -

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: 11/21/2015 4:56:54 AM