Friday, July 1, 2022

How to pass null value to textbox from database field null value - ASP.NET

 DataRow[] tempObj = Coursedt.Select("course_id='" + KeyVal + "'", "");

                DataRow temprow = tempObj[0];

(if allownull = true)

   txtOJTHours.Text = temprow["OJT_duration_in_hour"].ToString().Trim() == DBNull.Value ? "0" : Convert.ToString(temprow["OJT_duration_in_hour"]); 

or(if allownull = true)

 txtPracticalHours.Text = temprow["PracticaL_duration_in_hour"] == DBNull.Value ? "0" : Convert.ToString(temprow["PracticaL_duration_in_hour"]);

or (if allownull = false)

txtTheoryHours.Text = temprow["Theory_duration_in_hour"].ToString().Trim();

No comments:

Post a Comment