本文介绍了嗨名字没有显示名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 这是我的代码。 hi here is my code.protected void Search_Click(object sender, ImageClickEventArgs e) { SearchFacultyPL stPL = new SearchFacultyPL(); stPL.RoomNo = ddlSemister.SelectedValue; stPL.ExamDate = ddlDate.SelectedValue; stPL.eSession = ddlSession.SelectedValue; //stPL.aNo = ddlAno.SelectedValue; SearchFacultyBLL stBLL = new SearchFacultyBLL(); DataTable dt = new DataTable(); dt = stBLL.SearchRoomDetails(stPL); if (dt.Rows.Count > 0) { grdTimeTable.DataSource = dt; grdTimeTable.DataBind(); } if (connection.State!= ConnectionState.Open) { connection.Close(); } connection.Open(); SqlCommand cmd5 = new SqlCommand(); SqlDataReader dr5; cmd5.Connection = connection; cmd5.CommandText = "select facultycode from fAllotmentTab where RoomNo='" + ddlSemister.SelectedValue + "' and ExamDate='" + ddlDate.SelectedValue + "' and eSession='" + ddlSession.SelectedValue + "'"; dr5 = cmd5.ExecuteReader(); //if (dr5.Read()) //{ // labelmsg.Text = "Alloted Faculty : " + dr5.GetValue(0).ToString(); //} //else { labelmsg.Text = "Alloted Faculty : "; } labelmsg.Text = (dr5.Read()) ? "Alloted Faculty : " + dr5.GetValue(0).ToString() : "Alloted Faculty : "; 当我搜索并且我想将该教师名称显示给该标签时。但是没有显示任何人可以建议我吗?when i search and i want to display that faculty name to that label.but its not displaying can any one suggest me?推荐答案 if (dr5.HasRows) { dr5.Read(); var someValue = dr5["myColumnName"]; if (!DBNull.Value.Equals(someValue) { string someStringValue someValue as string; if (!string.IsNullOrEmpty(someStringValue) ... } //if} //if 但是为什么你认为数据集中只有一行?通常数据阅读器用于读到最后一行。 -SA 这篇关于嗨名字没有显示名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-30 01:47