Author: ginger_asp | Posted on: 11/3/2010 12:07:27 PM | Views : 307

my table field allows null values. but my code below does not work unless a value is assigned to my variable even though the glable variable is initialised to 0; tried the DBNull.Value - still, it gives me error as the table in question is linked and expecting a value.
protected void gvHotel_SelectedIndexChanged(object sender, EventArgs e) { int hotelId = (int)gvHotel.SelectedDataKey.Value; if (hotelId != null) { ViewState["HId"] = hotelId; } else { hotelId = Convert.ToInt32(DBNull.Value.ToString()); } }
 
...

Go to the complete details ...