to change value of Client Side Select html control from database value....

hello forum,

 I have a select ..

Demo.aspx

<

select id="DropAccType" name="DropAccType">

<option>Select</option>

<option>Saving</option>

<option >Current</option>

<option>Regular</option>

<option>Demat</option>

</select>

I want to set the value of select by fetching the data from daabase

i.e.

In my table if I have Value current then when i request the demo.aspx then in select Control the

value Current should get selected.....

Please help me to sort this out...

 

Thnx in advance..

0
nitsb
3/14/2007 2:30:33 PM
asp.net.web-forms 93655 articles. 5 followers. Follow

3 Replies
1012 Views

Similar Articles

[PageSpeed] 1

Hi-

I could be misunderstanding your problem, but would the DropDownList control work better for you in this situation?  Unless you have compelling reasons to use a straight "select" tag, the DropDownList handles a lot of difficult tasks for you such as preselecting a value.

Cheers,

-Mike

 

0
mikebridge
3/14/2007 6:05:58 PM

ya that will do...

but i want to do that by using Select control....

whether it is posible to do that..

0
nitsb
3/15/2007 7:01:03 AM
Hi,
Please look at this sample:

<select id="Select1" runat="server" style="width: 223px">
<option selected="selected"></option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>


protected void Page_Load(object sender, EventArgs e)
{
for (int i = 0; i < Select1.Items.Count; i++)
{
if (Select1.Items[i].Value == "4")
Select1.SelectedIndex = i;
}
}

Hope it helps.

0
Raymond
3/16/2007 3:32:09 AM
Reply:

Similar Artilces:

Accessing values on the server for controls whose values were changed client-side
Let's say that I have two server controls, a label and a textbox: <asp:Label ID="Label1" runat="server" Text="Old value"></asp:Label> <asp:TextBox ID="TextBox1" runat="server" Text="Old value"></asp:TextBox> Then I run some client-side code that changes their values: document.getElementById('Label1').innerHTML = 'New value'; document.getElementById('TextBox1').value = 'New value'; In the browser, they both visually have the value "New value".  Howev...

when loading a previously created record on to form, some controls are missing values(controls are depended on values selected in other controls)
Hello - I have created a page for Editing records.  this page will open up a chosen record and allow user to edit the data.On the form, I have 3 drop down lists.   The second dropdown list should fill values depending on value chosen in first dropdown list.  The third dropdown list should show/fill values depending on value chosen in second dropdown list.So taking this into count, i have several records with various data.  When I open-up/load a record in Edit form, only the first dropdown list has a value selected that was the pre-existing va...

how do i assign a database value to client side control
Hi all: "<input name="txtDate" type="text" /> <a href="javascript:calendar_window=window.open('Calender.aspx?formname=frmCalendar.txtDate','calendar_window','width=165,height=200');calendar_window.focus()">    Calendar </a>"   calender.aspx code: "Private Sub Calendar1_SelectionChanged(sender As Object, e As EventArgs)  Dim strjscript as string = "<script language=""javascript"">"  strjscript &= "window.opener." & _        Httpcontext.Current.Request.Querystring("formname") & ".value...

How can I set client side values as server side values?
Hi, Can anyone tell me how I can get client side values such as document.referrer, navigator.appName etc... into server side scripts? There are some client side values I'd like to set as session vars and insert into the db? How do I go about this? Thanks for any pointers Davlon PS (I'm using powersite 7.1.0.300) Pass them as page parameters, e.g., http://myserver/myurl?document.referrer=whatever&navigator.appName=yadayada Then, in your server-side script, just loop through the document.value array and get these values. -- pbm_hopethishelps, Roy Kie...

Selected value in select list with javascript based off value in database
 I've got a classic asp page with a select list. I need the select list's selected value to be whatever the user selected when they created their account. I've been trying to use <body onLoad="onLoad();"> to call my function, and then I'm trying to specify which value should be selected in the function. Also, when the select list selected values change, there is a javascript function I call to disable text boxes. I think there is an issue with my javascript function, and I can't find any examples of this from good ole' google.  My j...

The value set to controls at client side donot persist for each page load, else it is again set to the default value...??
 I am trying to set date to the textbox field using javascript (Client side), the function is as follows. function From_calendarPicker(){                                var    sDPath = "../Calender.aspx";                 var    oWin = window.showModalDialog(sDPath, null, "dialogWidth:300px;dialogHeight:250px;help:0;status:0;scroll:0;center:1");  &nbs...

Clearing Web Controls Values from a Web Form
I have a web form and after a user submit it I want to clear the form so that they may submit another entry. I have seen examples in VB of how to loop thru a web form and clear the controls, but I need a C# solution. I have tried the following code, while it does not give me an error, it does not clear the controls on the form. Any suggestions? Thanks! foreach (Control parent in Page.Controls)         {             foreach (Control child in parent.Controls)           ...

Read selected value from dropdownlist control which I add items on the client side
I have an asp :dropdown control to which I add items on the client side by javascript code how can I read what client selected in Server side ASP.NET? always selected value is the first item also I can see it's items count but every item value and text will be System.Data.DataRowView Hi basel,You wouldn't have to do this. DropDownList's items are in ViewState which was saved in server side. You could to use TextBox or Input (hidden) to save your selected value.Good Coding!Javier Luna http://guydotnetxmlwebservices.blogspot.com/ from Villa El Salvador for world!...

Question re: accessing web control values via client-side javascript
This block of variables gets generated dynamically from my _PreRender event of my formView : <SCRIPT Language='JavaScript'>  var chkInvertAliasID = 'ctl00_ContentPlaceHolder1_FormView1_chkEditInvert';  var chkAct_CurAliasID = 'ctl00_ContentPlaceHolder1_FormView1_chkEditAct_Cur';  var radBuy_SellAliasID = 'ctl00_ContentPlaceHolder1_FormView1_radioEditBuySell'; </SCRIPT> Now on the client-side I get a handle to above-declared var's : function QuoteConvention(obj) {         var objChkInvert = document.getElementById(chkInv...

Client side Values to Server values
Hi all, I'm using Visual Studio 2005 and C#.Net  I have one big security problem. I have one web page for user login. When user click in button "Login" i run some functions of javascript for detect pki credentials and i write the credentials in some textboxes. When the login process end, the user must click in another button for redirect the application to another page. I want pass the login credentials to target page, but i can´t use querystrings in url because is not secure ans i don´t want use cookies because some users have disableded cookies. I want...

HTML.select (UI helper) how to build a select list with value not equal to the display value
Hi Guys, I have a newbie question on HTML.select (UI helper). One of the tutorial I have come across shows the following: "string [] SelectList = new string[]{'Apple', 'Orange','Mango','Banana'};" "Html.Select('FruitList',SelectList)" it will give me:value = "Apple"  "Apple " However, I would like to have the following instead: value = "1"  "Apple " What should I do on the VIEW in order to achieve this? thx, George what you need to do is create a collection to use for your data sou...

How to take value from client side control from server side code?
Hi all, I would like to know that, how to access client side control in server side code? Here is an example.. I am having the textBox in client side like <input type="text" id="textBoxUsername" name="textBoxUsername"/> I need to take the value from this textBox in button click event which is server side code. private void buttonShow(object sender, System.EventArgs e) { //I need to access this textBox here. } How to do that? Thanks R. eswaran. hi you need to make it run at server. <input type="text" id="textBoxUsername"...

Retreiving a value from a web form within a web user control
Hi  I have a page (web form) that retreives some data from a database. To be more specific: at some point when user clicks a button (in the web form) there is some ID number retreived from a database in code behind. At the same time the Visible property of the nestet web user control is chamged to true. I want than forward the ID to the web user control so that a grid view can load data from a database for that ID. How can I access that data (the ID) within a web user control context nested in that page?  Kind regards   Check this ;ink  http://www.codeproject.com/K...

Dropdownlist selected value passes first value in list no matter what value is selected. why ?
 HI . I have a dropdownlist. Databinds ok but when I must pass a value as a Selected value it always passes the first value in the list even if I select another value. I tried to set the ddl to enableviewstate false but it doesn't change anything. Any ideas ? Code below, thanksLoading the ddl:       productCategories = CatalogAdmin.Admin_Product_Categories_NotIn(productId);        for (int i = 0; i < productCategories.Rows.Count; i++)        {            // obtain category id and name            categoryId = productCategories.Rows[i]["CategoryId"].ToString();            categoryName = productCategories.Rows[i]["Name"].ToString();            // populate the list boxes            categoriesListAssign.Items.Add(new ListItem(categoryName, categoryId));        }   ddl button click    protected void assignButton_Click(object sender, EventArgs e)    {            //Request the product ID from the query string            string pr...

DropDownList value selected base on database value?
Hi, is there anyway how I can allow my dropdownlist (on pageload event) to select the value base on the value found in the database, in addition I also want the dropdownlist to contain other values too however the selectedValue must be the one found in the database. Sorry if it sounds confusing. I'm using VB.NET 2003 with ASP.NET Thanks. Hi,Whatever you want to get selected for your dropdown use following code.if(dropdownid.items.findbyvalue("value") != null){    dropdownid.items.selecteditem = false;    dropdownid.items.findbyvalue("value").selected = t...

Control.Value and Control.SelectedItem.Value
Can someone explain to me the difference between say, Dropdownlist.SelectedItem.Value and Dropdownlist.SelectedValue?? Just curious, Thanks!Tim These are going to return the same thing. dropdownlist.selectedvalue is a shortcut to get the currently selected value in the dropdown. If that is all you want then you can just use that. If you want to access the currently selected item you can use dropdownlist.selecteditem and that return the item and you can then access any of the item's properties, including in this case the value property. If this post answered your question please r...

server side control passing value of self in client side function
I have a server side dropdownlist control.It contains values as:"#00FFFF""#FF00FF""#FFFF00"When the selectedindex is changed by the client I want to assign the value of the dropdownlist to a <div id="example"></div> evelement.pseudo:document.getElementbyId('example').bgcolor=dropdownlist.valueHow can I do this? I think I somehow need to attach a function to my dropdownlist which passes its own value as a parameter to a function...any suggestions?Thanks!please mark answers as 'Answered' and post back solutions when you figure stuff out that isnt in the post already. You ...

HTML select , selected value changes when clicking refresh multiple times
https://bugzilla.mozilla.org/show_bug.cgi?id=421103 Can anyone think of a workaround? The bug is causing us major issues, leading our users to think data is changing for no apparent reason. This same thing happens if you use the back button as well. Thanks in advance! Jerry DuVal Pace Systems Group, Inc. 800.624.5999 www.Pace2020.com ...

how can i Fill the controls on web page by selecting value from dropdownlist control.
  Hi,  Currentlly i am working on a web application where i require to fill the web form with the selected item in a text box. for example i have dropdown control named supplier_name, and i want to fill all the other controls values from database on the form when i select name from that supplier_name box,i.e , if i select name1, then related to that name, its code,address ,city should appear on related text boxes. I have done the same in windows application with c# , but the problem with web application(asp.net) is that, when i select Supplier _ it reloads the page and i loose the values in that combo box...i have heard of postback method but i donno how to use it to implement the same. please any one send me answer..   Hello friend,  Yes, for sure you're experience this error because of the postback. You are populating the dropdown with data on the page_load event, correct? If so you just have to do it on the first time, because the ViewState will mantain the date between postbacks. To do this is quiet simple, just had this code over the code where you populate your main drop down:if(!IsPostBack) { //your code goes here }Hope it helps!!!  ...

Issue obtaining values in server-side from dropdownlist when updating value using client-side script in master page
HiI got a page in a contentplaceholder of a master page. There is two pulldowns. I populate the first one using server side coding and then use client-side javascript. So far so good. The issue is that upon a postback I try to collect the select value of the second pulldown and there is no data in the pulldown and no selected item. I tried using control.selectedvalue (nothing) or searching the form controls Stringvariable = oForm.FindControl("Control")Thing is I've done this before in 1.1 outside of a master page and it works.Thanks in ad...

Based on selected value from HTML.Dropdownlist, the values to be fetched
Hi,  I'm using Html.DropDownList.  When selection within this box changes, I need to retrieve the values from table based on the selected id(datavaluefield) of dropdownlist. Here my code ViewPost.cs viewpage <%=Html.DropDownList("CategoryID",ViewData["CategoryID"])%>  ---- based on selected value from the user the below table should fetch the value the db <table>        <tr>                   ...

Html.RadioButton sets all values to selected value after postback?
When using the Html.RadioButton() html helper with a value field that is an Enum to ModelBind() to, once you have chosen a value all the radio buttons of that name group are set to the chosen value instead of the value you gave it thereby making it impossible to select a different value. Related stackoverflow question: http://stackoverflow.com/questions/277607/htmlradiobutton-sets-all-values-to-selected-value Hi Thank you for reporting this. We are aware of this problem in the Beta release and have already filed a bug for this on our end. Thanks, Jacques I wrote a full explanation ...

Setting the Parameter Value to the Property Value of a Web Control
I want to filter my DetailsView with a declarative parameter. In my case, I am setting the SqlDataSource's parameter values based on the value of 2 TextBox controls on the page. I have a SP that does a SELECT based on 1 of the parameters passed in (either an ID or phone number). Param Name          Value MemberID          TextBox1.Text Phone               TextBox2.Text I want to assign a default value of 'null' for b...

retrieving checkboxlist values from database
HiI'm using a CheckBoxList server control and trying to select certain values which are retrieved from a database.  How ever, i'm only getting one checkbox 'checked' even when there are multiple values. Public Sub getFacilities(ByVal queryString As String, ByVal connectionString As SqlConnection) Using connectionString connectionString.Open() Dim command As New SqlCommand(queryString, connectionString) Dim reader As SqlDataReader = command.ExecuteReader() While reader.Read() CType(FormView1.FindControl("facilityCheckBoxList"), CheckBoxList).SelectedValue = reader(0) End While End Using End Sub  The single value which is selected is correct, and i have also run the SQL command seperatly which shows that there should be multiple values! thanks  Hi!, This is happening because you r resetting selectedvalue everytime while running the loop, so in the end of the loop it gives u the selected value for the last value. U have to check each item for the checkboxlist and find a match for the value from the sqldatareader, if matches then set that Checkboxlist item's selected property = true; While reader.Read(){ for (int i = 0; i < chk1.Items.Count;i++) { if (reader(0) == chk1.Items[i].Value) chk1.Items[i].Selected = true; } } Hope this will help. Regards HiThats spot on, thanks for that - i've converted somthing similiar ...

Web resources about - to change value of Client Side Select html control from database value.... - asp.net.web-forms

Database - Wikipedia, the free encyclopedia
A database is an organized collection of data . The data are typically organized to model aspects of reality in a way that supports processes ...

Database - Wikipedia, the free encyclopedia
... requiring information. For example, modelling the availability of rooms in hotels in a way that supports finding a hotel with vacancies. Database ...

Oracle: Fear Not, ’12c’ Database Nearing Its Breakout, Says Credit Suisse
... from cloud computing applications in 2016, along with the adoption by customers of the its “ 12c ” version of its flagship relational database ...

Enterprises want to run databases in containers
More than three out of four IT decision makers are interested in running stateful applications like databases within containers, according to ...

NFL mock draft database 2016: Tracking Giants picks from around the Internet
Let's keep track of mock drafts from around the Internet as the 2016 NFL Draft approaches. Can we find a consensus for the New York Giants?

NTTC's Liquid Products Database making steady progress
NTTC's Liquid Products Database making steady progress Modern Bulk Transporter NTTC is asking carriers to suggest “proprietary blends” for ...

Herbalife sinks on database error report
Herbalife said it had overstated growth in the number of "active new members" in some instances in the past three quarters due to database errors. ...

Consumer Group Sues DOT For Failure To Create Searchable Database Of Safety Defects
... about safety defects. One safety group says this hasn’t happened, and is suing DOT Secretary Anthony Foxx in an effort to make this database ...

TSA Will Finally Be Given Access To Counterterrorism Database To Screen Airport Workers
TSA Will Finally Be Given Access To Counterterrorism Database To Screen Airport Workers

Architizer raises $7 million to launch a new products database
US media company Architizer has received $7 million in venture capital to help launch an online products database for architects and designers ...

Resources last updated: 3/6/2016 6:11:46 PM