Click here to Skip to main content
15,912,400 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
protected void Page_Load(object sender, EventArgs e)
{
Loademployeegeofencee(strUnitNo);
}


private void Loademployeegeofencee(object strUnitNo)
{
//here i load the value from the database to the dropdownlist "Superuserid1"
//this works fine

}

protected void Superuserid1_SelectedIndexChanged(object sender, EventArgs e)
{
string st;
st=Superuserid1.SelectedItem.value;

//code to be executed

}
the issue here is when i set the break point in st its showing null the value is not coming inside st
Posted
Comments
moneymakermaster 11-Nov-11 9:03am    
Does your table consists of null as first value?

You have to bind the data 1st only,
not in the postback
so,try this
C#
if (!IsPostBack)
{
 Loademployeegeofencee(strUnitNo);

 }
 
Share this answer
 
Try :
C#
st=Superuserid1.Text.ToString()


or only
C#
st=Superuserid1.Text
 
Share this answer
 
v2
It will work, and Working for me
C#
void Superuserid1_SelectedIndexChanged(object sender, EventArgs e)
       {
           string s=Superuserid1.SelectedValue;
       }
 
Share this answer
 
v2
Comments
ashok_89 11-Nov-11 9:00am    
no its not working there is something to do with the pageload i think so,if u could see the code fully may know
May Be their is a problem With dataBinding to DropDown list in the Method
SQL
Loademployeegeofencee(object strUnitNo),
Are u setting the Values of
C#
Superuserid1.DataTextField="Text";
Superuserid1.DataValueField = "CorrespondingValues";

in that method..?

Make sure of it, otherwise it will not set the Value property;
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900