Retrieving DropDownList 'value' (C#/ASP.NET)

Oct 19, 2010

On my page, whenever a DetailsView is updated, I must audit the changes into a database. On most pages this works perfect, as there were just textboxes - however on a page I am working on right now, with dropdownlists, my code isn't working.

Basically, what the code does is captures the Updating event of the SqlDataSource, creates a datareader to look at the contents of the row before it's updated, compares the contents to the parameters in the Update query of the SqlDataSource, and if one has changed to log this in a field in the Audit table. An extract of my code is below:

while (reader.Read())
{
for (int i = 0; i < reader.FieldCount; i++)
{
try {
if (reader[i].ToString() != [code].....

When the control is on a dropdownlist, it seems to never go 'into' the IF even though the fields are different. Do I need to do something special to compare the values of dropdownlists? Note I believe the value is stored as an int in my table.

View 1 Replies


Similar Messages:

Web Forms :: Retrieving Selected Value From Unbound Dropdownlist?

Dec 10, 2010

I have an unbound dropdownlist that is populated in my page_load event. I want to retrieve the text of the selection from the dropdownlist. I'm

using dropdownlist.selectedvalue.tostring(), which works on original page_load but not when I make another selection, even though autopostback is set to true. Do i have to write something in the selectedindexchanged event when not databinding?

View 6 Replies

Asp.net - Retrieving The Value Of Div

Jul 12, 2010

iam using an empty div in which i am assigning values through an external javascript via ajax call iam also using an fck editor what i want to do using an internal javascript i want to set the contents of that div in the textarea of fckeditor but in the internal javascript when iam accessing the contents of that div then it is showing "undefined"....

View 1 Replies

C# - Retrieving Xml Value Into String

Dec 23, 2010

In the following XML structure how do i retrieve the name value and put this into a string? (i am using a XPathNavigator in my method)

<testsystem>
<test>
<name>one</name>
<name>two</name>
<name>three</name>
</test>
</testsystem>

The name will get displayed in the boundcolumn of a datagrid. I was able to get a attribute with a syntax alike this: (but when changing the xml struture it no longer holds a attribute value)

string name = nav.GetAttribute("name", "")

But have no luck getting the value with a nav as of yet. The purpose is to be able to use it for the following object so i can put name into it.

test t = new test() { Name = name, Questions= new List<Questions>() };

View 3 Replies

Asp.net - Retrieving A Row From The GridView

Jan 12, 2011

I want to retrieve a cell from the selected row in GridView. Please tell me how to do tanks in advance

View 2 Replies

Data Controls :: Populate City DropDownList Based On District DropDownList Selection

Sep 2, 2012

i have 2 DDL in my page that when users select item from ddldistric1 item in ddlcity1 will change these are my code

 protected void DDLcity1_SelectedIndexChanged(object sender, EventArgs e)
{
BindDistrictC();
}
private void BindDistrictC()

[code]...

View 1 Replies

Data Controls :: Clear Cascading DropDownList Selection When Parent DropDownList Is Changed

Jan 8, 2013

I am having two dropdownlist in my project,one dropdownlist for empid, another dropdownlist for month, if the user select the empid, the values are retrieved in the textbox.

In the second dropdownlist, if the user select the month in the dropdownlist it will display the leave details, its all working fine, if the user again select the first dropdownlist that means empid, I want to show the second dropdownlist as select month, how can do this.....

View 1 Replies

C# - Disable Or Enable 2nd Dropdownlist In Aspx Based On Selected Choice Of The 1st Dropdownlist Box

Apr 15, 2010

I am having a problem with disabling DropDownList based on the chice of 1st DropDownList, there is no post back occuring, and it is a template based web app here is the current code:

<script type="text/javascript">
$(function() { var dropDownList1 = $('#<%= ddlUserType.ClientID %>');
var dropDownList2 = $('#<%= ddlMember.ClientID %>'); dropDownList1.change(function(e) {
if ( jQuery("#ddlUserType").val() != "ETOC") dropDownList2.removeAttr('disabled'); e.preventDefault();
else
dropDownList2.removeAttr('enabled'); e.preventDefault(); }
} );
</script>

what is happening now is page is blank and if I remove the above code everything shows, where I am going wrong. here is the plain and final javascript code which worked:

<script language="javascript">
function CheckDropDownState(lstbox)
{
if (lstbox.selectedIndex == 3) { document.forms[0].ddlMember.disabled = 1; }
else { document.forms[0].ddlMember.disabled = 0; }
}
</script>

and thew .aspx code: <asp:dropdownlist id="ddlUserType" runat="server" onclick="CheckDropDownState(this);"></asp:dropdownlist>

View 2 Replies

Forms Data Controls :: How To Extract Value From A Dropdownlist After Bind 7 Column Name In A Dropdownlist

Mar 29, 2011

I have a table and 7 column name.

I bind the 7 column name in one dropdownlist.

Now the problem is,how do I extract the data value in a dropdownlist?

For example,

Dropdownlist contain 7 column name

-subject_name

-subject_code

-venue

-time

-seat_no

-admission_no

-subject_id

when I click the subject_name,I want it to appear in a gridview

Example

Math|9.00-10.00|Hall|18|09090J|...

Below is my current codes which I have a problem.

protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection("Data Source= EN\SQLEXPRESS;" + "Initial Catalog=ms;Integrated Security=SSPI");
SqlDataAdapter adapSel;
string mySQL = "SELECT '" + dd_list.SelectedValue+ "' FROM examtimetable ";
adapSel = new SqlDataAdapter(mySQL, conn);
conn.Open();
DataSet dsSel = new DataSet();
adapSel.Fill(dsSel);
GridView1.DataSource = dsSel;
GridView1.DataBind();
conn.Close();
}
Previously I have bind 7 column name in my dropdownlist
protected void Page_Load(object sender, EventArgs e)
{
if (Page.IsPostBack == false)
{
SqlConnection conn = new SqlConnection("Data Source= EN\SQLEXPRESS;" + "Initial Catalog=ms;Integrated Security=SSPI");
SqlCommand sqlCmd = new SqlCommand("select column_name from information_schema.columns where table_name='examtimetable' and COLUMN_NAME not like '%ID'", conn);
conn.Open();
SqlDataReader ds;
ds = sqlCmd.ExecuteReader();
dd_list.Items.Clear();
dd_list.DataSource = ds;
dd_list.DataTextField = "Column_Name";
dd_list.DataValueField = "Column_Name";
dd_list.DataBind();
dd_list.Items.Insert(0, "Select Option");
ds.Close();
conn.Close();
}
}

View 10 Replies

DataSource Controls :: Display Employee Name In Dropdownlist Depend On Departments Name In The Other Dropdownlist

Nov 15, 2010

i use 2 dropdownlist with 2 object data source first dropdownlist to display departments name using object datasource (field to display DeptName , value of field DeptID)

second dropdownlist to display Employee name but depend on departments (field to display EmpName , value of field EmpID)

how to display employee name in dropdownlist depend on departments name in the other dropdownlist

2 tables

1 table deprtments with column (DeptID , DeptName , DeptDescription)

2 table Employee with column (EmpID , DeptID , EmpName)

View 3 Replies

Forms Data Controls :: What Is The Code For Dropdownlist After Binding All Columns Name In A Dropdownlist

Mar 28, 2011

Currently,below is my code.

protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection("Data Source= E\SQLEXPRESS;" + "Initial Catalog=k;Integrated Security=SSPI");
SqlDataAdapter adapSel;
string mySQL = "select column_name from information_schema.columns where table_name='examtimetable' '" + dd_list + "'";....

I receive an error "Incorrect syntax near 'System.Web.UI.WebControls.DropDownList'."

View 3 Replies

Web Forms :: Display All Items In Child DropDownList When ALL Is Selected In Parent DropDownList

Sep 6, 2012

protected void DDLzone1_SelectedIndexChanged(object sender, EventArgs e)
{
BindDistrict();
}

[Code]......

here when i click on ALL item from ddlzone1  it just "ALL" item in ddldistrict

i want when i select "ALL" item from ddlzone1 in ddldistrict14 show all data from database

View 1 Replies

Web Forms :: Populate Multiple Cascading DropDownList On Selection On Main DropDownList

Aug 12, 2012

i have 3 drop down list in my page

1-ddlzone1
2-ddldistrict1
3-ddlstore1

this is  ddlzone1 code

protected void DDLzone1_SelectedIndexChanged(object sender, EventArgs e) {
DDLstore1.Items.Clear();
DDLstore1.Items.Add(new ListItem("select center", ""));
DDLstore1.AppendDataBoundItems = true;
SqlCommand _cmd = new SqlCommand("selectcenter", _cn);

[CODE].....

View 1 Replies

Forms Data Controls :: Make Another Dropdownlist Visible = False When Clicking In Dropdownlist On The Same Detailsview?

Mar 8, 2010

I want to making another dropdownlist visible=false when clicking in dropdownlist on the same detailsview?

View 4 Replies

Retrieving Data From Database?

Apr 4, 2010

i've two tables trans-mstr having columns as acc_no_from,date,particular,wd_dt,amt,balance and third_party_transfer(table2) having columns as acc_no_frm,acc_no_to,date,amt.now i wnt to retreive date ,particular,wd_dt,acc_no_to,amt,balance where the acc_no_from in third_party_transfer is equal to the no.entered in the textbox of the webpage.i've used datagrid view to show all this.i'm using c# n sql server2005 in this i'm a beginer

View 1 Replies

VS 2005 Retrieving The Com Class?

Feb 17, 2010

ERROR: Retrieving the COM class factory for component with CLSID {000209FF-0000-0000-C000-000000000046} failed due to the following error: 80070005

a. I had configured the DCOM on the server

b. If i run the APP on the server with any user: RUN!

c. If i run the APP using the Internet Explorer from any PC everything is fine until i try to call word

e. I have put all template (.dotx) on the server, on the PC and nothing WORD.

I am using office 2003.

View 2 Replies

Syntax For Retrieving A Value From A SqlDataSource?

Dec 28, 2010

the syntax for retrieving a value from a SqlDataSource? I've managed to get it working using numbers to represent the column, but I'd much rather use it's DB name?

[Code]....

View 2 Replies

Retrieving Cookie From A Container In MVC And C#

Jul 14, 2010

//Controller code
CookieContainer cookieContainer = new CookieContainer();
//makes new cookie here
cookieContainer.Add(myCookie);

//Service/Facade code
//myCookie gets passed here

How do I pull the cookie out of the container to make sure it's the right cookie?

View 1 Replies

Web Forms :: Retrieving Emails Into Asp.net

Jun 29, 2010

Hey there

I have in my database emails table

and i am retrieving all the mails from that table in a string to be included in

message.To.Add()

HOW can i put it in the right format ( separated by Comma and space ) while selecting them from the database?




thank you

View 3 Replies

Asp.net - Displaying Milliseconds When Retrieving From DB

Jan 28, 2011

in my db i have:

2011-01-28 12:03:46.223


when displaying on .aspx page,

<%# Eval("ModifiedDateTime") == null ? " " : Eval("ModifiedDateTime")%>


it displays on the grid like this:

12/2/2010 8:43:18 AM


how do I format it like the default format shown when I query my db?

View 1 Replies

ADO.NET :: Retrieving A Value With Select Statement?

Jan 16, 2011

I have the following select statement :

string Statement = "SELECT * FROM Car WHERE brand = Bmw;

how is it possble to display the result from the statement, because when i display the result exp: LblInfo.Text = Statement;

The result is : SELECT * FROM Car WHERE Brand = Bmw

View 5 Replies

ADO.NET :: Retrieving A Single Value With A Procedure?

Feb 25, 2011

I have a stored procedure with two input parameters which calculates the distance between two points. When I call it from aspx.cs I get an error.

Here is the code:

CreateDataSet();
float raz;
String str = "";
float min = 3.4F;
String clo = "";

[Code]....

and the error I get is:

Exception Details: System.Data.SqlClient.SqlException: Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.

Source Error:

[Code]....

When I test the procedure in SQL Server Management Studio everything is OK and I get a value 539.551855770807 for the certain input parameters.

View 2 Replies

Access :: Retrieving A Value From Database?

Aug 20, 2010

I want to be able to take a select statement like: SELECT password FROM table WHERE user_name = @user_name and compare it with what was entered in a form text box. I have tried:

AccessDataSource1.SelectParameters("password").DefaultValue
= TextBox1.Text

AccessDataSource1.Select() (not sure how this works or what to set it equal to)

I also tried to connect to the database with a basic ADO connection that I got off another forum, with no luck

View 4 Replies

C# - Retrieving Substring Of A Bound Value?

May 10, 2010

I am binding some data to control, but want to limit the number of character of a specific field to a 30 first characters. I want to do it, if it's possible, on aspx page.

I tried this:

Text='<%# String.Format("{0}", Eval("Title")).Substring(0,30) %> '

But got this error: Index and length must refer to a location within the string. Parameter name: length

View 3 Replies

C# - Retrieving ListView Using FindControl?

Feb 13, 2011

I am trying to retrieve two listviews from an ascx control for the purpose of saving them to a PDF file:

<TagCloud:TagCloudControl ID="TagCloudControl1" runat="server" />

I get the following error: TagCloudControl1 is a field but is used like a type and an object reference is required for the non-static field, method or property..

ListView lv1 = (TagCloudControl1)ListView.FindControl("ListView1");
ListView lv2 = (TagCloudControl1)ListView.FindControl("ListView2");
lv1.RenderControl(htWriter);
lv2.RenderControl(htWriter);

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved