Tracking Forums, Newsgroups, Maling Lists
Home Submit Tracker Forums
  Advanced Search
  HOME    TRACKER    ASP.NET


Advertisements:










Web Forms :: Deselect Initial Selected Value In Dropdownlist?


I have a dropdownlist which is bound to datatable. After databinding, first item in the list is automatically selected. I have tried ClearSelection() and SelectedIndex = -1 to deselect initial value. But I still can't.


View 3 Replies (Posted: Mar 10, 2009 02:51 AM)

Sponsored Links:

Related Forum Messages For ASP.NET category:
Set Dropdownlist Selected Value On Initial Page Load
I posted a similar question previously, but none of the answers worked and I've been scouring all over the web trying to find a solution. My situation, I have a Edit Window webform with a dropdownlist (Note: to avoid confusion, I'm using Telerik extensions only to decorate the webform):

<%@ Page Language="VB" CodeFile="EditFormVB.aspx.vb" Inherits="EditFormVB" %>
<%@ Register Namespace="CustomBoundField" TagPrefix="custom" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Edit Pop-up</title>
</head>
<body class="">
<form id="form1" runat="server">
<div>
<script type="text/javascript">
function CloseAndRebind(args) {
GetRadWindow().BrowserWindow.refreshGrid(args);
GetRadWindow().close();
}
function GetRadWindow() {
var oWindow = null;
if (window.radWindow) oWindow = window.radWindow; //Will work in Moz in all cases, including clasic dialog
else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow; //IE (and Moz as well)
return oWindow;
}
function CancelEdit() {
GetRadWindow().close();
}
</script>
<asp:ScriptManager ID="ScriptManager2" runat="server" />
<telerik:RadFormDecorator ID="RadFormDecorator1" runat="server" Skin="Vista" DecoratedControls="All" />
<br />
<br />
<asp:DetailsView ID="DetailsView1" DataKeyNames="ID" runat="server" AutoGenerateRows="False"
GridLines="None" DataSourceID="detailsSqlDataSource" Height="50px" Width="125px"
BorderWidth="0" CellPadding="0" CellSpacing="7">
<Fields>
<asp:BoundField DataField="TS_DESCRIPTION" HeaderText="TS_DESCRIPTION" SortExpression="TS_DESCRIPTION" />
<asp:BoundField DataField="TS_TITLE" HeaderText="TS_TITLE" SortExpression="TS_TITLE" />
<asp:CommandField ShowEditButton="True" />
<asp:CommandField ShowInsertButton="True" />
</Fields>
</asp:DetailsView>--%>
<telerik:RadScriptManager ID="RadScriptManager1" runat="server" />
<telerik:RadFormDecorator ID="RadFormDecorator1" runat="server" Skin="Vista" />
<br />
<br />
<asp:DetailsView ID="DetailsView1" runat="server" Height="400px" Width="745px"
AutoGenerateRows="False" DataKeyNames="TS_ID" DataSourceID="SqlDataSource2"
EnableModelValidation="True">
<Fields>
<asp:TemplateField HeaderText="Category">
<EditItemTemplate>
<%--<asp:DropDownList ID="TTCategory" runat="server" DataSourceID="ReqCategoryData" SelectedValue='<%# Bind("TS_NAME") %>' />--%>
<asp:DropDownList DataSourceID="ReqCategoryData" DataTextField="ReqCategory" DataValueField="ReqCategory"
ID="reqCategoryDropDown" runat="server" AppendDataBoundItems="true" AutoPostBack="true" >
</asp:DropDownList>
</EditItemTemplate>
</asp:TemplateField>
<asp:CommandField ButtonType="Button" EditText="Update" ShowEditButton="True"
ShowCancelButton="True">
<ItemStyle HorizontalAlign="Center" />
</asp:CommandField>
</Fields>
</asp:DetailsView>
</div>
</form>
</body>
</html>

And in the code behind, I'm setting the datasource for the dropdownlist and using a function to query the DB for the name of the value I want to set as the selected value when the page loads initially: Partial Class EditFormVB Inherits System.Web.UI.Page

Public Shared category_Name As String = ""
Dim ddlDataSource As New SqlDataSource
Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
DetailsView1.DefaultMode = DetailsViewMode.Edit
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Me.Page.Title = "Editing record"
''Setup DropDownList SqlDataSource
ddlDataSource.ID = "ReqCategoryData"
Page.Controls.Add(ddlDataSource)
ddlDataSource.ConnectionString = ConfigurationManager.ConnectionStrings("TTPRODReportsQuery").ConnectionString
ddlDataSource.SelectCommand = "SELECT TS_NAME AS ReqCategory FROM dbo.TS_SELECTIONS WHERE (TS_FLDID = 5299 AND TS_STATUS = 0) ORDER BY TS_NAME"
Dim args As New DataSourceSelectArguments
ddlDataSource.Select(args)
''Set max length of Title field to 70 characters
Dim dvrTest As DetailsViewRowCollection = DetailsView1.Rows
Dim TitleTB As TextBox = dvrTest.Item(0).Cells(1).Controls(0)
TitleTB.Attributes.Add("onkeydown", "isMaxLen(this)")
TitleTB.Attributes.Add("maxlength", "70")
Dim myDDL As DropDownList = DetailsView1.FindControl("reqCategoryDropDown")
''Perform dropdown list population operations
If Page.IsPostBack = False Then
Dim ticket_ID As String = getDataKey(DetailsView1)
''Fetch Category ID
Dim sqlText As String = "SELECT TS_REQCATEGORY FROM USR_ITFAC WHERE (TS_ID = " + ticket_ID + ") "
Dim reqDataReader As SqlDataReader = GetDataReader(sqlText)
reqDataReader.Read()
Dim category_ID As String = reqDataReader(0)
''Fetch Category name using the categoryID and set as selected value in dropdown list
sqlText = "SELECT TS_NAME FROM TS_SELECTIONS WHERE (TS_ID = " + category_ID + ") "
reqDataReader = GetDataReader(sqlText)
reqDataReader.Read()
category_Name = reqDataReader(0)
myDDL.DataBind()
myDDL.Selectedvalue = category_Name //<--this value gets set only when debugging,
End If
End Sub
Private Function GetDataReader(ByVal sqlText As String) As SqlDataReader
Dim dr As SqlDataReader
Dim sqlConn As SqlConnection = New SqlConnection(ConfigurationManager.ConnectionStrings("TTPRODReportsQuery").ConnectionString)
sqlConn.Open()
Dim sqlCmd As SqlCommand = New SqlCommand(sqlText, sqlConn)
dr = sqlCmd.ExecuteReader(System.Data.CommandBehavior.CloseConnection)
Return dr
End Function
End Class

The dropdownlist does get populated appropriately, however when I attempt to set the value, it doesn't reflect when the page loads; the dropdownlist just gets populated and no value is set to selected in the markup, so the first value is shown by default. The odd thing is that when I'm debugging, the value appears to get set when I step through the function, it's as if the selectedvalue is getting reset as soon as the function exits and proceeds to load the page.

SOLUTION: Had to add a separate function that is called onLoad from the DropDownList after the after Page_Load is done executing. Still unresolved is why the the DropDownList rebinds after the Page_Load.

IN HTML:
<asp:DropDownList DataSourceID="ReqCategoryData" DataTextField="ReqCategory" DataValueField="ReqCategory"
ID="reqCategoryDropDown" runat="server" AutoPostBack="true" OnLoad="DDL_DataBound">
IN CODE-BEHIND
Public Shared category_Name As String = ""
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Me.Page.Title = "Editing record"
''Setup DropDownList SqlDataSource
ddlDataSource.ID = "ReqCategoryData"
Page.Controls.Add(ddlDataSource)
ddlDataSource.ConnectionString = ConfigurationManager.ConnectionStrings("TTPRODReportsQuery").ConnectionString
ddlDataSource.SelectCommand = "SELECT TS_NAME AS ReqCategory FROM dbo.TS_SELECTIONS WHERE (TS_FLDID = 5299 AND TS_STATUS = 0) ORDER BY TS_NAME"
Dim args As New DataSourceSelectArguments
ddlDataSource.Select(args)
''Set max length of Title field to 70 characters
Dim dvrTest As DetailsViewRowCollection = DetailsView1.Rows
Dim TitleTB As TextBox = dvrTest.Item(0).Cells(1).Controls(0)
TitleTB.Attributes.Add("onkeydown", "isMaxLen(this)")
TitleTB.Attributes.Add("maxlength", "70")
Dim myDDL As DropDownList = DetailsView1.FindControl("reqCategoryDropDown")
''Perform dropdown list population operations
If Page.IsPostBack = False Then
Dim ticket_ID As String = getDataKey(DetailsView1)
''Fetch Category ID
Dim sqlText As String = "SELECT TS_REQCATEGORY FROM USR_ITFAC WHERE (TS_ID = " + ticket_ID + ") "
Dim reqDataReader As SqlDataReader = GetDataReader(sqlText)
reqDataReader.Read()
Dim category_ID As String = reqDataReader(0)
''Fetch Category name using the categoryID and set as selected value in dropdown list
sqlText = "SELECT TS_NAME FROM TS_SELECTIONS WHERE (TS_ID = " + category_ID + ") "
reqDataReader = GetDataReader(sqlText)
reqDataReader.Read()
category_Name = reqDataReader(0)
myDDL.DataBind()
End If
End Sub
Protected Sub DDL_DataBound(ByVal sender As Object, ByVal e As System.EventArgs)
If Page.IsPostBack = False Then
Dim myDDL As DropDownList = DetailsView1.FindControl("reqCategoryDropDown")
myDDL.Items.FindByValue(category_Name).Selected = True
End If
End Sub

Posted: Jul 22 10 at 18:56

View 1 Replies!   View Related
Web Forms :: Deselect Selected Date On Second Click?
I am selecting multiple dates from a calendar control, asp.net. I want the user to be able to deselect a date if he/she click on the date a second time ,, is it possible ,, how can i do that?

Posted: Feb 05, 2011 04:13 PM

View 5 Replies!   View Related
Web Forms :: Deselect All Previously Selected Dates On Button Click Event?
I am selecting multiple dates on a calendar control ,, and then i insert them into DB. The problem happens after i insert, if i want to add new list of dates, once i start selecting on calendar all last selected dates appear (get selected on calendar) Does this mean these dates are saved in Session or what? Here is the code I am using:

[Code]....

Posted: Feb 01, 2011 09:39 PM

View 5 Replies!   View Related
Web Forms :: How To Set DropdownList Initial SelectedIndex
I have a form with a dropdownlist named ddlCustomer. When the page loads I want to set the selectedindex to the 1st item in my ddl and then call a routine that updates the form to the data for that customer. I have tried the following code, but the ddl selectedindex remains at -1. How do I get this to change?

[code]....

Posted: May 01, 2006 02:17 PM

View 15 Replies!   View Related
Web Forms :: How To Set Initial Value Of Dropdownlist In User Control
I have tried to construct a user control named EventCategory, that holds 2 dropdownlists to select an event category. Depending on the selection in the first dropdownlist, the second dropdownlist must be repopulated with items corresponding with the first dropdownlist selection.Here is my control :

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="EventCategory.ascx.cs" Inherits="EventCategory" %>

<table border="0">
<tr> [code]...

This works fine for a simple web page, but when i place the user control in a InsertItemTemplate of a FormView and I change the
mode of the FormView to FormViewMode.Insert by an ImageButton in the page where the FormView is located I can not initial select
a dropdownlist item through the Category property of the user control. I know it is because the formview is switched to insert mode during a postback so the IsPostBack block of the OnPreRender override gets skipped. Is there a better way to wtite the user control so that I can select an initail value in a dropdownlist that works also in a template of a FormView.

Posted: Dec 29, 2009 02:20 PM

View 1 Replies!   View Related
Web Forms :: Dropdownlist Selectedvalue Always Fires Initial Value Instead Of Selection?
dropdownlist selectedvalue not firing.

It shows the inital value after i selected the value from dropdown box and submitted

HTML Code:

<asp:DropDownList ID="DropDownList1" runat="server" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">
</asp:DropDownList>

.CS File:

Protected void page_load()
{
if (!IsPostBack)
{
Label_Testing.Text = DropDownList1.SelectedValue;
Label_Testing1.Text = DropDownList1.SelectedIndex.ToString();......

Posted: Feb 15, 2011 12:47 AM

View 4 Replies!   View Related
SQL Reporting :: How To Select/deselect Records In Report And Export The Selected Records Into Excel
my requirement is that SSRS 2005 report should show all records with checkboxes(or can be by any other means of flagging ?) .

Now the records for which checkboxesare checked or flagged are only to be included in the exported excel sheet or pdf .

Posted: Jun 10, 2010 07:46 AM

View 2 Replies!   View Related
Web Forms :: DropDownList - Page Loads Initial Value Should Blank Until Clicking The Dropdown Button
i have dropdownList Binded to a data source and its working fine But want i want to do is when the page loads its initial value should Blank until clicking the dropdown button

Posted: Jul 10, 2010 07:09 AM

View 6 Replies!   View Related
How To Change The Initial Value Of A DropDownList
I know that this question has been asked here before and I tried to implement the solutions I have found here but without success

Posted: Mar 22, 2011 04:42 PM

View 2 Replies!   View Related
Forms Data Controls :: Dropdownlist Selected Value Of The Selected Item?
I can assign the selecteditem to the dropdownlist of the repeater, how can i set the value of the below selectedItem to empty because i don't want to save the text "name" to the database.

my code behind:

foreach (RepeaterItem data in repeater1.Items)
{
((DropDownList)data.FindControl("ddl_name")).SelectedItem.Text="name";
}

Posted: Dec 04, 2009 03:07 AM

View 2 Replies!   View Related
State Management :: Viewstate And Dropdownlist / Initial Selection Is Lost Each Time The Page Refreshes
I have a simple search page with a drop down list that I would like the value to persist on refresh..basically the user will select their location from the dropdownlist and this will be used to populate a gridview. After this the page is set to refresh at a set interval and use the same location data initially selected by the user. However the initial selection is lost each time the page refreshes.

p.s system is to old for ajax!

<meta http-equiv="Refresh" content="300" />
<script runat="server">
Dim connectionString As String = ConfigurationManager.ConnectionStrings("****").ConnectionString
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
If Not IsPostBack Then
Dim conn As SqlConnection
conn = New SqlConnection(connectionString)
Dim Locationcommandtext As String
Locationcommandtext = "SELECT * FROM [Location] ORDER BY [Location]"
Dim loccomm As SqlCommand
loccomm = New SqlCommand(Locationcommandtext, conn)
Dim reader As SqlDataReader
Try
conn.Open()
reader = loccomm.ExecuteReader()
Locations.DataSource = reader
Locations.DataValueField = "LocationID"
Locations.DataTextField = "Location"
Locations.DataBind()
Catch ex As SqlException
Response.Write("SQL Error:
" & ex.ToString())
Finally
conn.Close()
End Try
Else
'"Viewstate should kick in here"
End If
End Sub
</script>

Posted: Jan 13, 2011 10:16 AM

View 6 Replies!   View Related
C# - Disable Or Enable 2nd Dropdownlist In Aspx Based On Selected Choice Of The 1st Dropdownlist Box
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>

Posted: Apr 15 10 at 17:30

View 2 Replies!   View Related
Web Forms :: Have Deselect Function To Radiobuttonlist?
I want to let the user have 2 option:

1. Only can select one of the item from the radiobuttonlist
2. Not select any item

But, i found that the radiobutton cannot deselect the item once it has been selected. (Thiscause my option 2 cannot work) How to have a deselect function to the radiobuttonlist?

Posted: Oct 19, 2008 01:10 AM

View 6 Replies!   View Related
Web Forms :: How To Deselect ListBox Programmatically
Is there any way to deselect alistbox Programaticaly?

Posted: Nov 22, 2009 09:08 AM

View 4 Replies!   View Related
Web Forms :: Select Checkbox To Deselect Other?
ive 3 CheckBoxes I'd like to only let the user select one at a time so each one must be able to deselect the others when checked. how would i Do this?

Posted: Apr 15, 2010 11:53 AM

View 3 Replies!   View Related
Disabling Dropdownlist Inside A Gridview Based On Value Selected On Another Dropdownlist?
what i m trying is i hav two dropdownlists inside the gridview... namely say ddonsiteoffsite and ddhours... now what i want is if the selectedtext of ddonsiteoffsite is "onsite" the ddhours should b disabled... i tried the code snippet but ... its not disabling the ddhours... can someone help me please..

<asp:TemplateColumn HeaderText=" OnSite/OffSite" >
<ItemTemplate>
<asp:DropDownList ID="ddOnsiteOffside" runat="server" onchange="ToggleOnOff(this)">
[code].....

Posted: Jan 11 at 8:35

View 2 Replies!   View Related
Dropdownlist's Selected Index Value Is Not Printing The Selected Value
.Aspx Page
<asp:DropDownList
ID="ddlkeyword"
runat="server"
Width="204px"
DataTextField="Form"
DataValueField="Form"
OnSelectedIndexChanged="ddlkeyword_SelectedIndexChanged"
>
</asp:DropDownList>
<asp:Button
ID="Button1"
runat="server"
Text="Submit"
Width="110px"
OnClick="Button1_Click"
/>
my aspx.cs
protected
void Page_Load(object sender,
EventArgs e)
{
fillddlkeyword();
}
protected
void Page_Init(object sender,
EventArgs e)
{
}
private
void fillddlkeyword()
{
string StrSql =
"Select distinct(formName)as formName from tbl_form";
oDB.RunDBQuery(StrSql, out oRS);
DataTable dt =
new
DataTable();
dt.Columns.Add("Form");
if (oRS.HasRows)
{
while (oRS.Read())
{
DataRow dr = dt.NewRow();dr["Form"]
= oRS["formName"].ToString();
dt.Rows.Add(dr);
}
oRS.Close();
}
oDB.Close();
// ddlkeyword.DataTextField = dt.Rows[0].ToString();
//ddlkeyword.DataTextField =
ddlkeyword.DataSource = dt;
ddlkeyword.DataBind();
//GridView1.DataSource = dt;
//GridView1.DataBind();
}
protected
void Button1_Click(object sender,
EventArgs e)
{
}
protected
void ddlkeyword_SelectedIndexChanged(object sender,
EventArgs e)
{
fillddlkeyword();
Response.Write(ddlkeyword.SelectedItem.ToString());
}

Posted: Jan 13, 2009 08:52 PM

View 4 Replies!   View Related
Web Forms :: Mutually Exclusive Checkboxlist Or Deselect Radiobuttonlist?
I was about to use a radiobuttonlist to offer three items, but then I realized that the user would need some way to deselect all items. So I decided to use a checkboxlist with the three items. How do I make the items mutually exclusive, while maintaining the ability to deselect all once one's been selected?

Posted: Dec 16, 2004 09:20 PM

View 7 Replies!   View Related
Forms Data Controls :: Select / Deselect Checkboxes In A Grid?
I am using a gridview where there are 6 cols and the last col consist of checkboxes. I wrote a code such that all the checkboxes in the col are selected or deselected at once by clicking the header checkbox. Now the issue is since I am using paging for the Gridview, once I select the checkboxes in the last col and go for the next page and come back to the previous page the checkboxes are deselected. I want to keep the checkboxes selected even after pagination.

Posted: Jan 05, 2010 06:14 PM

View 1 Replies!   View Related
Web Forms :: Treeview - Auto Select / Deselect All Sub Nodes - When Parent Clicked
If you have a treeview like below:

+ Parent Node
+child 1
+child 2
+child N

How do you auto select/deselect all nodes including the parent node?

Posted: Sep 23, 2008 09:05 PM

View 4 Replies!   View Related
Web Forms :: Set Selected Value Of Dropdownlist?
I have a dropdownlist that I populate in my .cs file when the page is loaded, however how do I make the selected value of the dropdownlist to be a specific value? For instance I populate my ddl with the values of 'month' and since its now september, I want the ddl to display 'september' as the value that is shown on the ddl, and only when the user clicks the ddl arrow button, will the list of months appear.

Posted: Sep 30, 2009 03:17 AM

View 16 Replies!   View Related
Should The Selected Index Or Selected Value Be Used To Set A Dropdownlist
I am binding months to a list 0-13 items default selection is 0 months duration, and years 0-8 items and 0 years is the default selection.As I know there are always going to be 12 months in a year, I could use selectedvalue or selectedindex without any perceived problem. Is there a reason why I should not use either/or of the two properties to select a list item?

Posted: Nov 26 10 at 9:29

View 2 Replies!   View Related
Web Forms :: DropdownList And Setting Selected Value?
I have built a simple web page using VB .NET 2005, (and Visual Studio 2005) with a dropdownlist. The datasource for the dropdownlist is a SqlDataSource which I dragged on to form in design view. I am pulling a list of about ten records from a sql server 2000 database table. When I run the page, it works fine (dropdownlist shows the 10 or so items from the database when I click the dropdown button).

Now, what Iwant is to set the value in that drop down box in VB code so that when the web page displays, I can control which of those 10 or so items is selected in the dropdowlist. So I use the Page_Load event and put a statement in there the sets the SelectedValue. But now when I run the web page, I get an error indicating the item I am trying to set is not in the list. I know the item is in the list coming from the database, but I suspect it is a timing issue - that when I try to set the SelectedValue in the PageLoad event, the SqlDataSource control has not populated the list for the DropDownList yet.

Should I put the code that sets the SelectedValue somewhere else besides the Page_Load event?

Posted: Jul 01, 2006 03:15 AM

View 7 Replies!   View Related
Web Forms :: Setting Dropdownlist Selected Value
My problem is I need to set selected value of a drop down list to a value I retreive from a database. The example only has a know value.


Below is the HTML and Code.
<asp:DropDownList
id="ddlCatogory1st1"
DataSourceID="srcCatogory1st1"
DataTextField="CategoryName"
DataValueField="CategoryID"
AutoPostBack="true"
Runat="server" />
<asp:sqldatasource id="srcCatogory1st1"
ConnectionString="server=(local);database=db;Trusted_Connection=true"
SelectCommand="SELECT CategoryID, CategoryName FROM Categories WHERE ParentCategoryID is null ORDER BY CategoryID"
Runat="server" ></asp:sqldatasource>
Sub Page_Load()
DISPLAY_CATEGORY()
End Sub
Sub DISPLAY_CATEGORY()
ddlCatogory1st1.DataBind()
ddlCatogory1st1.Items.FindByValue("A").Selected = True
End Sub

When I run this page I get

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
Line 222:
Line 223: Sub DISPLAY_CATEGORY()
Line 224: ddlCatogory1st1.DataBind()
Line 225: ddlCatogory1st1.Items.FindByValue("A10").Selected = True
Line 226: End Sub

Even if I take out the databind I get the same error.

Posted: Jan 15, 2010 05:10 PM

View 30 Replies!   View Related
Web Forms :: Dropdownlist Not Displaying The Selected Value?
drpdwncity.SelectedItem.Text = READER("CITY").ToString.Trim

i am using the above code

when the dropdown is displayed it shld display the vlaue from the databse , but here it displays the first value instead

Posted: Sep 20, 2010 08:00 AM

View 6 Replies!   View Related
Web Forms :: Save DropDownList Selected Value?
How can Isave dropdownlist selected value? (mabey into cookie?)I have a language selection dropdown, but on page reload it resets te value.

Posted: Oct 08, 2010 11:48 AM

View 9 Replies!   View Related
Web Forms :: Fetching DropDownList Selected Value?
I'm havingissues getting the selecteditems and value afterDatabinding a dropdown list. I have a button event with dropdownlist2.Selecteditem.text, but will always get the "-- Select --" as the SelectedItem.text ?

[Code]....

Posted: Sep 10, 2010 07:39 PM

View 9 Replies!   View Related
Web Forms :: Dropdownlist - Default Value Is Not 'selected Value'?
i have created a dropdown list that is populated from a sqlserver datasource.

i have a separate sql command which uses the dropdownlist.selected value as a parameter and returns the command value to a label.

it mostly works fine but with one problem. when the page loads, the label value is null, because it doesn't seem to treat the dropdownlistdefault value as a selected value. when i use the dropdownlist to select a value, this is fine and the label begins to display the expected value.

is there anyway I can make the default value when the page is loaded act like a manually selected value, so the label control never displays a null value?

Posted: Jan 09, 2009 11:16 AM

View 8 Replies!   View Related
Web Forms :: Check For Different Selected Dropdownlist Items?
I have a page with 5 drop down list controls. Each control has the same 10 list items.

When the user clicks a button to submit, how can I check to make sure there are 5 different items selected?

Posted: Oct 12, 2009 10:25 PM

View 2 Replies!   View Related
Web Forms :: Get Selected Value With Dropdownlist Dynamically Created
I dont know if this post existed already but i couldnt be able to find it out...! sorry for repeating if so. i have ma dropdownlist created dynamically and now i want when i press on a button to display the selected value within the msgbox for example. The button is already created dynamically also and i manage to put the event handle on it. Now I have 3 dropdownlists and the problem is i dont know how to get the ID of those 3 dropdownlists to use the one selected and display its value.

Posted: Dec 11, 2009 07:36 PM

View 7 Replies!   View Related
Web Forms :: DropDownList - Can A Value Be Sent As The Selected Item From Another Webpage
I would like to be able to pass a new value into a dropdownlist control from another webpage and cause an autopostback to occur. How can this be done?

Posted: Jun 09, 2010 02:46 PM

View 27 Replies!   View Related
Web Forms :: Particular Country Get Marked If Selected From Dropdownlist
learning asp.net and prepare my final year project. i've problem in dropdownlist hope i found answer here. I've two dropdownlist each consist four listitem as follows

dropdownlist1
uk,usa,india,singapore.

dropdownlist2
uk,usa,india,singapore.

if anyone of the country selectedfrom dropdownlist1 then dropdownlist2 that particular country automatically get masked or readomly

Posted: Jan 03, 2010 12:12 AM

View 4 Replies!   View Related
Web Forms :: Retrieving Selected Value From Unbound Dropdownlist?
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

usingdropdownlist.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?

Posted: Dec 10, 2010 11:24 PM

View 6 Replies!   View Related
Web Forms :: How To Get The Selected Value When The Page Load In Dropdownlist
how to get the default value from a dropdownlist when the form load.

Posted: Oct 26, 2010 06:20 PM

View 13 Replies!   View Related
Web Forms :: DropDownList Doesn't Change Selected Value
I have a dropdownbox which does an autopostbackwhen selected index has changed. Butthe selected value never changed.

[Code]....

[Code]....

Posted: Aug 10, 2010 12:00 PM

View 9 Replies!   View Related
Web Forms :: Selected Value In DropdownList In Gridview Does Not Update?
I've created a DropDownList in a GridView, which works ok, but when I select "two", when the page posts back the first item "one" is selected. Can anyone tell me how to fix this?

I've found a few posts asking this question, but not found a solution. Viewstate is not disabled. Am I missing a DataBind somewhere?

[Code]....

Posted: Aug 21, 2009 06:30 PM

View 8 Replies!   View Related
Web Forms :: Dropdownlist Not Keeping The Selected Value After Submit?
I've many input elements one of which is,a radio button group with Autopostback set to true. After selecting one item from the radio button, the drop down list below fetches values from database and is refreshed. I choose some value in the dropdown listand submit the form. I've many server side validation controls. When I submit the form, if any of the server validation fails, it'll show the error message in the form. Butthe value I choose in the dropdown list disappears and it shows the first value of the dropdown list.

How to show the selected value in the list after submission of form?

Below is the partial code from my form. When I type anything other than "Hello" is the "Comments" text box, it will show the error message. I know I can use, other validators to check this. But purposely I want to use Customvalidator.

My C# code

[Code]....

MyASP.net code

[Code]....

Posted: Feb 14, 2011 05:36 AM

View 22 Replies!   View Related
Web Forms :: How To Enable Text Box From Dropdownlist Selected Value
I have a drop down list.

<asp:DropDownList ID="DropDownList1" runat="server"
AutoPostBack="True">
<asp:ListItem>a</asp:ListItem>
<asp:ListItem>b</asp:ListItem>
<asp:ListItem Selected="True" >others</asp:ListItem>
</asp:DropDownList>
<asp:TextBox ID="TextBox1" runat="server" Visible="False"></asp:TextBox>

By clicking "others" it should display TextBox1.

Posted: Dec 31, 2009 08:20 AM

View 4 Replies!   View Related
Web Forms :: Get A Dropdownlist To Keep It's Selected Value And Not Return To The Default Value?
I have a dropdownlist that is not bound to a datasource, I have hard coded a few items in the list cause the list is always constant and will never grow and there are only 4 entries init. Anyway, after i load the page and make a selection from the dropdownlist and do a postback, the dropdown always returns to the default selection...which tells the users to make a selection.How do I get the dropdown to keep the selected value after the postback? I want to be able to display the selected value all through until another selection is made.

Posted: Jan 11, 2011 04:33 PM

View 6 Replies!   View Related
Copyright 2005-08 www.BigResource.com, All rights reserved