473,805 Members | 2,027 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

dropdownlist problem - HELP URGENT

2 New Member
hello

i have a problem with a dropdown list i am populating from an Access table.
I´ve seen this problem in other discussions but i can´t seem to find the solution. please help.

my .aspx has the following inside a form:

[HTML]<asp:DropDownLi st id="_Pais" runat="server">
</asp:DropDownLis t>
<asp:RequiredFi eldValidator id="vr_Pais" runat="server" ControlToValida te="_Pais" Display="None" EnableClientScr ipt="false" ></asp:RequiredFie ldValidator>[/HTML]


my .aspx.cs has the following inside a function, which is not Page_Load, but is called upon just before the html code in the .aspx:


Expand|Select|Wrap|Line Numbers
  1. string qryP = "SELECT PaisES AS Texto, PaisES AS Valor FROM Paises ORDER BY PaisES";
  2.  
  3. OleDbConnection cnP = new OleDbConnection(
  4.                     System.Configuration.ConfigurationSettings.AppSettings["accessConnectionString"]);
  5. cnP.Open();
  6. OleDbDataAdapter daP = new OleDbDataAdapter(qryP, cnP);
  7. OleDbCommandBuilder cbP = new OleDbCommandBuilder(daP);
  8. DataSet dsP = new DataSet();
  9. daP.Fill(dsP, "Paises");
  10.  
  11. ((DropDownList)GetControl("_Pais")).DataSource = dsP.Tables["Paises"].DefaultView;
  12. ((DropDownList)GetControl("_Pais")).DataTextField= "Texto";
  13. ((DropDownList)GetControl("_Pais")).DataValueField= "Valor";
  14. ((DropDownList)GetControl("_Pais")).DataBind();
  15.  
  16. cnP.Close();
  17.  
  18. ((DropDownList)GetControl("_Pais")).Items.Insert(0, "-Select-");
  19.  
  20. if (!Page.IsPostBack)
  21. {
  22.        ((DropDownList)GetControl("_Pais")).Items.FindByText("-Select-").Selected = true;
  23. }
The dropdownl list populates just fine. but when i press submit, the RequiredFieldVa lidator acts as if there was no item selected. If i take away the RequiredFieldVa lidator, the submit will work just fine, and the selected item will be saved into the DB.

Please help, i'm on a deadline :( :confused:
Aug 8 '06 #1
0 1470

Sign in to post your reply or Sign up for a free account.

Similar topics

1
1253
by: reiks | last post by:
I have a dropdownlist control . I want to bind the data to it from an existing datagrid on my page i.e I wnat to specify the datagrid name instead of the datatable name. Is it possible? How can I bind data from a datagrid to ddlistbox?
5
2079
by: Bob N | last post by:
I have an ASP.NET web page -- several auto-post back DropDownLists that perform a query against a relatively large database (3 to 4 seconds delay) that repopulate a couple of datagrids, comboboxes and a chart (using dotnetCharting control) on the same page. This works just fine on its own. However, when I integrated the page into the rest of the site, it is then placed inside a frameset. Again, the page seems to work fine EXCEPT under the...
6
1781
by: VB Programmer | last post by:
I have an itemtemplate in a datagrid. I'm trying to set it's value based on data. Having no trouble with the textbox. But, how do I do the same thing for a dropdownlist???? <ItemTemplate> <asp:DropDownList id="ddlYesNo" runat="server" > <asp:ListItem Value="-">-</asp:ListItem> <asp:ListItem Value="Yes">Yes</asp:ListItem> <asp:ListItem Value="No">No</asp:ListItem> </asp:DropDownList>
7
4549
by: AG | last post by:
Hi, ASP.NET 2.0 web app I have a GridView utilizing template columns and bound to an objectdatasource. In the edit template of one column there is a dropdownlist bound to another objectdatasource. The dropdownlist displays the appropriate values when entering edit mode. However when I try to update, I receive the following error.
1
5244
by: Laurahn | last post by:
Hi: How can i display tooltip message on a dropdownlist template control inside a GridView Footer. I found this code working well, but it dosen't work inside a gridview: </head> <body> <div id="tooltip"></div>
1
3026
by: iswar | last post by:
Hi friends.. Im trying to bind a value from dropdownlist placed in gird view to another cell. i want to update a database field with the selected value from dropdownlist and which must be bind to gridview... please help me .. im using sql server2000 as datasource.. public partial class Propertydetails : System.Web.UI.Page { protected static string connect; string ct, struName; protected void Page_Load(object sender,...
1
4948
by: Brett | last post by:
I have a DropDownList in an ASP.NET web form that is populated with items from a lookup table by binding that DropDownList to a SqlDataSource. However, the items in the lookup table can change over time. The problem is that when an item has been removed from the lookup table, and a user wants to retrieve a record that used the deleted item, the following error occurs: 'ddlAssignedTo' has a SelectedValue which is invalid because it...
3
1705
by: EdisonCPP | last post by:
Hi, I have a DetailsView with a template field with a dropdownlist added to it. If the data coming into that field were put into a textbox, it would look like: Small|Medium|Large|X-Large. I need to break that out into dropdownlistitems with each text being the value also. I've tried using a ObjectDataSource unsuccesfully. What would be a valid way of handling this?
6
4284
by: shashi shekhar singh | last post by:
Respected Sir, I have to create multiple dynamic dropdownlist boxes and add items dynamically in <asp:table> server control but problem occurs , i.e. except of fist dropdown list no dropdownlist boxes are generating a postback.here is a code . protected void Page_Load(object sender, EventArgs e) { int selected_question = (int)Session; if (!Page.IsPostBack) { display_blueprint(); string...
0
10356
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10361
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10103
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9179
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7644
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6874
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5536
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5676
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4316
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.