Web Forms :: Fetching DropDownList Selected Value?
Sep 10, 2010
I'm having issues getting the selecteditems and value after Databinding a dropdown list. I have a button event with dropdownlist2.Selecteditem.text, but will always get the "-- Select --" as the SelectedItem.text ?
[Code]....
View 9 Replies
Similar Messages:
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
May 7, 2015
I have two pages manager and user both have drop downs as
Week, Months and Years.
User have to enter some data week wise for each months and Manager have to approve that.
To Approve manager select months and week from dropdown on his own page and then navigate to User page.
How does I should bind the drop down so that if manager select 1st week from it's page and goes to view link of user then in drop down of user selected value shold be the same as selected by Manager on his own page.
View 1 Replies
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
Jan 11, 2011
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].....
View 2 Replies
Dec 17, 2012
I am having a 2 dropdown list, in the first dropdown I have 3company names,for each company I am having separate tables,every table have a empcode, if the user select the company name in the 1st dropdownlist, as per company selected the 2nd dropdownlist it will fill the list of employee codes as per the selection..
View 1 Replies
Nov 26, 2010
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?
View 2 Replies
Jan 15, 2010
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.
View 30 Replies
Sep 20, 2010
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
View 6 Replies
Oct 8, 2010
How can I save dropdownlist selected value? (mabey into cookie?)I have a language selection dropdown, but on page reload it resets te value.
View 9 Replies
May 7, 2015
I have items in a sql table that i populate a dropdown list with. so on page load the items are sent to dropdown list. I have a button on the page with the dropdown list that onclick it launches another page that allows more items to be added to the database table.
What I want to do is to refresh/update the list of items in the dropdown list when the second page is closed. In addition the last item added to the table will be the selected item in the drop down list.
View 1 Replies
May 7, 2015
I am inserting a new states in the table from dropdown list , the dropdown list has new in the list, clicking on new gets me a pop up which takes the new state and inserts in a table. My requirement is I want to get the last inserted state in the dropdownlist and its id to be selected as soon as insertion is done.
The second function is to insert the contact details where i have countryid,stateid,cityid
protected void stateSave(object sender, EventArgs e) {
using (SqlConnection conn = new SqlConnection(cs)) {
SqlCommand cmd = new SqlCommand("newStates", conn);
cmd.CommandType = CommandType.StoredProcedure;
SqlParameter outparm = new SqlParameter("@stateID", SqlDbType.Int);
[Code] ....
View 1 Replies
Jun 9, 2010
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?
View 27 Replies
Jan 3, 2010
learning asp.net and prepare my final year project. i've problem in dropdownlist hope i found answer here. I've two dropdown list each consist four listitem as follows
dropdownlist1
uk,usa,india,singapore.
dropdownlist2
uk,usa,india,singapore.
if anyone of the country selected from dropdownlist1 then dropdownlist2 that particular country automatically get masked or readomly
View 4 Replies
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
Oct 26, 2010
how to get the default value from a dropdownlist when the form load.
View 13 Replies
Aug 10, 2010
I have a dropdownbox which does an autopostback when selected index has changed. But the selected value never changed.
[Code]....
[Code]....
View 9 Replies
Feb 14, 2011
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 list and 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. But the 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]....
My ASP.net code
[Code]....
View 22 Replies
Jan 11, 2011
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.
View 6 Replies
Feb 23, 2014
based on the below image, May i know how if tick the checkbox, then will hide the selected data value only.
Example, hide "a", then will hide "a" data value only.
View 1 Replies
Aug 18, 2012
I have 2 dropdown list in my page
1- ddlzone1
2- ddldistrict1 and one button (search)
At first I select item from ddlzone1 click on search button according to below SP it search on database and show result...
ALTER procedure [dbo].[GetCustomersPageWise]
@PageIndex INT = 1
,@PageSize INT = 5
,@RecordCount INT OUTPUT
,@Region nvarchar(10)
,@District nvarchar(20)
[Code] ...
Now I want when users select item from ddlzone1 after that if they select item from ddldistict1 according to their selected item from ddlzone1 and ddldistrict1 it search in table and show result
Now how I can change my SP
I changed below code in SP but it didn't work
WHERE ([HOuse_info].Region = @Region or @Region='0') or ([House_Info] .District=@District or @District='0')
SELECT @RecordCount = COUNT(*)
View 1 Replies
May 7, 2015
System.Web.HttpException: Cannot have multiple items selected in a DropDownList.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Web.HttpException: Cannot have multiple items selected in a DropDownList.
I have a nested gridview and inisde a child grid there are several columns having dropdown and one add button. when add button is click a new row inside a child grid is created with an empty dataand previous row data have been saved in viewstate so that it can be bind wen add button is click to create new rows.My code is working fine when i dont select any dropdown list item and new row is also created but wen i select items from dropdown and click on add more button i get above error.
When add button is click
protected void ButtonAdd_Click(object sender, EventArgs e) {
Button gv = ((sender) as Button);
string[] ParentIdArray = gv.ClientID.ToString().Split('_');
int ParentId = int.Parse(ParentIdArray[1].ToString().Replace("ctl", "").Trim()) - 2;
int RecordCount = ((GridView)GVMain.Rows[ParentId].FindControl("grdAddHotel")).Rows.Count;
DataTable dtAddHotel = new DataTable();
dtAddHotel.Columns.Add("CostSheetId");
[Code] .....
View 1 Replies
Apr 22, 2013
I have dropdownlist in my page
In Page_load page I wrote below code
if (!IsPostBack) {
DDL1.Items.Insert(0, new ListItem("select city", "0"));
DDL2.Items.Insert(0, new ListItem("select region", "0"));
DdlDistrict.Items.Insert(0, new ListItem("select district", "0"));
}
And in this page I have btnInsert that when users click on it, it insert data in database
I want when users click on button all textboxs text be clear and all DDL selected Item clear so I set below code in btnInsert event
protected void imginsert_Click(object sender, ImageClickEventArgs e) {
SqlCommand _cmd = new SqlCommand("insertFreg", _cn);
_cmd.CommandType = CommandType.StoredProcedure;
_cn.Open();
_cmd.Parameters.AddWithValue("@address", txtsdd.Text);
_cmd.Parameters.AddWithValue("@Aname", txtAname.Text);
[Code] .....
But here when I click on button it clear textboxs text but it didn't do any thing on Dropdownlist i.e
If I select 'Paris' from DDL1 when I click on button I want It show in ddl1 'Select city'
But it show 'Paris' again
What should I do?
View 1 Replies
Mar 4, 2013
I have one dropdownList=DDLtradeO and one button=btnsubmit In Admin.aspx page
and I have House_info table that one of column's is T_name
here I want if users select State from DDLtradeO , in House_info table in T_name column insert "STATE"
and if users select other Item from DDLtradeO in T_name column insert "STORE"
so in behind code I wrote below code
protected void btnsubmit(object sender, ImageClickEventArgs e)
{
string T_name = DDLtradeO.Text == "State"?"State":"Store"
SqlCommand _cmd = new SqlCommand("registerspecial", _cn);
_cmd.CommandType = CommandType.StoredProcedure;
_cn.Open();
_cmd.Parameters.AddWithValue("@T_name", T_name);
_cn.close();
}
but here when I click on State Item or Other Item from DDLtradeO in both case it insert "STORE" in table
View 1 Replies
Jun 11, 2012
i am loading xml file from url and storing data into my database.i am binding that data with my dropdownlist bt the problem is wheneverr i select any option from ddl...by defaulst it takes the always takes first selected index...i.e value at the zeroth index value.....i really don't know what exactly the problem either the problem is with dropdown or the way i am loading xml file and binding it to dropdown.....below is my cs code.
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
[code]...
View 1 Replies