Hi Kobus, I suggest this solution: use javascript to check ur default value b4 post it to server.
var sDropDownList_HP = '<%=DropDownList_HP.ClientID %>';
// var slblMsg = '<%=lblMsg.ClientID %>';
function validateHospitalDropDownList()
{
var ddlHP = document.getElementById(sDropDownList_HP);
if(ddlHp.selectedIndex<1){
// document.getElementById(slblMsg).innerHTML= "Please select Hospital";
return false;
}
else{
return true;
}
}
In your asp code: there may be some button click event to post back to server: I assume u have that button,
OnClientClick="if(!validateHospitalDropDownList())return false;" Text="Submit" />
then add attribute OnClientClick and assign JS function to it, if this function return true, the form will post back normally, else no post back will occur. you can also add some code to show error msg in the JS function. Hint: in Data Null case, u can use ISNULL('value that can be null', 'new replace value'); function from SQL. Hope that works!