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

Home Posts Topics Members FAQ

[c#] dropdownlist from database and value send as parameter

Hello,

i have small problem - i have dropdownlist, which is populated from
database by stored procedure. I had autopostback attached to this list.
I'm using this as a parameter to another stored procedure. So, when i
was using asp:SqlDataSour ce and bind to him values from this
dropdownlist everything was ok. But when i'm doing this in code behind
using SqlCommand and trying to get value from this dropdownlist

sensor = Int32.Parse(Dro pDownList1.nSel ectedValue) ;

I got error. I can't find anything usefull for this kind of behaviour.
I hope somebody can help me

Piotrek
Nov 20 '06 #1
2 1633
"Piotrek "Alchemik"" <al**@epf.pl.sp am.wonwrote in message
news:ej******** **@matrix2.nntp .idg.pl...
I got error. I can't find anything usefull for this kind of behaviour.
I hope somebody can help me
Nobody can help you if you don't say what the error is...
Nov 20 '06 #2
Mark Rae wrote:
"Piotrek "Alchemik"" <al**@epf.pl.sp am.wonwrote in message
news:ej******** **@matrix2.nntp .idg.pl...
>I got error. I can't find anything usefull for this kind of behaviour.
I hope somebody can help me

Nobody can help you if you don't say what the error is...
The error is:
Input string was not in a correct format.

So i suppose i'm not getting int from dropdown list:

<asp:DropDownLi st ID="stateDropDo wnList" runat="server"
AutoPostBack="T rue" DataTextField=" ID_sensor"
DataValueField= "ID_sensor" visible = "False"
DataSourceID="S ensorFromTestow a">
</asp:DropDownLis t>
<asp:SqlDataSou rce ID="SensorFromT estowa" runat="server"
ConnectionStrin g="<%$ ConnectionStrin gs:testowaConne ctionString %>"
SelectCommand=" SelectSensor"
SelectCommandTy pe="StoredProce dure"></asp:SqlDataSour ce>

For sure this one works fine if i pass parameter to SqlDataSource, but
trying to parse them in code behind i got this error.

Hope this one helps

Piotrek
Nov 20 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
4379
by: Tim::.. | last post by:
Can someone please tell me how I go about preselecting an item in a drop drown list when I click the Edit Command in a datagrid? I have tried the following but it doesn't work for me! I would be really grateful for any assistance! Thanks
6
5547
by: Julius Fenata | last post by:
Dear all, I have created client-side scripting to trigger event onChange from code-behind, like this: DropDownList1.Attributes = "GenerateArticleID()"; At the script on Windows Form, I added this function to have the value of DropDownList1
2
7919
by: Dabbler | last post by:
In my Registrant FormView I have a DropDownList which loads data from a secondary SqlDataSource "sdsOfficeParks". I need the user to select an office park but save the selected value in the FormView's ObjectDataSource "odsRegistrant" . The following solution can't work because I need the ddl selected value bound to my odsRegistrant but both tables have the same column name for primary key. <asp:DropDownList ID="ddlOfficePark"...
4
4479
by: Sevu | last post by:
I am working with ASP.NET.I am using ReportViwer Control to show my report.I like to add dropdownlist with in the reportviewer control. ( Not top to the control some thing like that).I need to place dropdown near to Export link ( Excel and PDF Export).Is it possible to add at the dropdown list with in report viewer control?. I found the property as ReportViewer.Controls.Add.But its not working.Please help me. Regards, S.Sevugan.
0
1623
by: Ben | last post by:
Hi, It's about a database containing (for simplifying) three fields: 'placenr' (primary key), 'place' and 'color'. The records are updatable (Edit/Update button) in a gridview. For updating the field 'color', the selectedvalue of a dropdownlist must be used, containing all possible colors (red, blue ...), so the field 'color' is ReadOnly in the gridview. Everything works, but i still have 2 problems: 1)the new color in the field is...
3
1653
by: Jon Paal | last post by:
this text keeps showing up in my gridview dropdownlist "System.Data.DataRowView" How do I prevent this problem ?
0
1192
by: Jon Paal | last post by:
--dropdownlist value isn't being saved to database from FORMVIEW --field PriorityID is datatype "number" (integer) what's missing ???? '=========code============= <asp:Content ID="Content1" ContentPlaceHolderID="PageContentPlaceHolder" runat="Server"> <asp:AccessDataSource id="DataSource1" Runat="Server"
0
2228
by: lamolap | last post by:
i have 1 gridview , a dropdownlist inside a gridview and a commandfield of (edit, update and cancel) my gidview looks like this Edit Surname Initials ParkingBay CommandField Me Y dropdownlistvalue CommandField You m dropdownlistvalue i have 2 sqldatasource. the other one is for gridview and...
1
4270
by: shapper | last post by:
Hello, I am trying to display a DropDownList on an ASP.NET MVC view. SlidePaper.Targets contains the list of items and SlidePaper.Slide.Target contains the current value taken from the database for the given record ... This works but does not give the current value, only the list: <%= Html.DropDownList(null, "Targets") %.
0
9718
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9596
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10364
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
10370
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
9186
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...
0
6876
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
5545
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
5678
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3008
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.