private void dlUserName_SelectedIndexChanged(object sender, System.EventArgs e)
{
lblOpDesc.Text = "" + Session["gUserID"] + "";
string varUserName = dlUserName.SelectedItem.Value;
string strDSNUserID = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\\\\Paragon\\databases\\Super_6\\Test\\ParaNet\\ParaNet.mdb";
string strSqlUserID = " Select * from AspLoginUserTbl where UserName = '" + varUserName + "' ";
OleDbConnection myConnUserID = new OleDbConnection(strDSNUserID);
OleDbCommand myCmdUserID = new OleDbCommand(strSqlUserID, myConnUserID);
OleDbDataReader drUserID = null;
myConnUserID.Open();
drUserID = myCmdUserID.ExecuteReader();
if( dlAccessType.SelectedItem.Value == "Corporate"
{
lblRegion.Visible=false;
lblDistrict.Visible=false;
}
myConnUserID.Close();
}
When I select item from dlAccessType, first time is working.
When I do the same for the first item in the list,
It is giving error as given below,
"Object reference not set to an instance of an object. "
Line 299:
Line 300:
Line 301: if( dlAccessType.SelectedItem.Value == "Corporate"
Line 302: {
Line 303: lblRegion.Visible=false;
Source File: c:\inetpub\ Line: 301
Looks like dlAccessType.SelectedItem.Value is coming "Null"
value, when I select the item from the list at the second time.
It works good, when I select an item from the list at the first time.
Somehow When I do the same process at the second time, it is giving me an error.
Any help would be really apprecited..
Thanks in Advance.
{
lblOpDesc.Text = "" + Session["gUserID"] + "";
string varUserName = dlUserName.SelectedItem.Value;
string strDSNUserID = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\\\\Paragon\\databases\\Super_6\\Test\\ParaNet\\ParaNet.mdb";
string strSqlUserID = " Select * from AspLoginUserTbl where UserName = '" + varUserName + "' ";
OleDbConnection myConnUserID = new OleDbConnection(strDSNUserID);
OleDbCommand myCmdUserID = new OleDbCommand(strSqlUserID, myConnUserID);
OleDbDataReader drUserID = null;
myConnUserID.Open();
drUserID = myCmdUserID.ExecuteReader();
if( dlAccessType.SelectedItem.Value == "Corporate"
{
lblRegion.Visible=false;
lblDistrict.Visible=false;
}
myConnUserID.Close();
}
When I select item from dlAccessType, first time is working.
When I do the same for the first item in the list,
It is giving error as given below,
"Object reference not set to an instance of an object. "
Line 299:
Line 300:
Line 301: if( dlAccessType.SelectedItem.Value == "Corporate"
Line 302: {
Line 303: lblRegion.Visible=false;
Source File: c:\inetpub\ Line: 301
Looks like dlAccessType.SelectedItem.Value is coming "Null"
value, when I select the item from the list at the second time.
It works good, when I select an item from the list at the first time.
Somehow When I do the same process at the second time, it is giving me an error.
Any help would be really apprecited..
Thanks in Advance.