see the code:
%26lt;input type='hidden' id='hdCombo'%26gt;
%26lt;select id=someCombo onchage='saveChangedValue(this);'%26gt;
%26lt;options%26gt;......
%26lt;/select%26gt;
%26lt;script%26gt;
function SaveChangedValue(ddl)
{
document.getElementById('hdCombo').value = ddl.options[ddl.selectedIndex].value;
}
%26lt;/script%26gt;
and refer the hidden field in server-side code
e.g. in page load event as:
request.form(';hdCombo';)
if you are using server side combo box,
use in page-load:
srvCombo.attributes.add('onchange', 'saveChangedValue(this);')
here replace srvCombo to your Combo box IDI have to pass a hide int value whenever i change the value of the dropdownlist in asp.net. How to do?
If u r filling drop down lits from database u have to bind the dataset to control
1. First set properties of dropdownlist
DataTextField = ';ColumnName'; this will be visible on webpage
DataValueField=ColumnName'; this will be value which is invisible on web page
2. Bind dataset
drpdown.DataSource = dataset;
drpdown.DataBind();
3.Set AutoPostBack propertyof dropdownlist to true
and write what ever u want to werite in dropdown index changed event...
u can get id of the selected value by selectedvalue property...
If u dont understood mail me
with column names ur featching from database.
I will provide code for u...
-----------
Dropdown list has items colletion
and each item will have value and text fields
If u are filling dropdown list manually then give id in value and value in text fileds....
U can get ids by selectedvalue property of dropdownlist
No comments:
Post a Comment