First off, have you tried debugging your code by setting a break point at your
Button
Click
event for you to verify it it hits there? If it hits, then step into your code and see the value of
Session
.
Second, when referencing a value from Session object make sure to check for
null
first to avoid unexpected error. For example:
if(Session["TENDER"] != null){
string tende= Session["TENDER"].ToString();
SqlDataSource2.SelectParameters["tnid"].DefaultValue = tende;
}
Third, if you are passing
Session
value for your
Select
command, then you can try using the
SessionParameter instead. For example:
<selectparameters>
<asp:sessionparameter name="ID" sessionfield="Tender" type="Int32" />
</selectparameters>