朋友們,我需要關於在網頁方法中顯示錯誤消息或任何其他消息的幫助。我試着寫一些函數來顯示消息,如果返回值是「0」或返回字符串變量的長度是「0」但沒有結果。你能給一些解決方案嗎? 是的,當然。這裏是我的代碼: -如何顯示來自webmethod的消息?
[WebMethod]
public string[] GetCompletionCompany(string prefixText, int count)
{
if (count == 0)
{
count = 10;
}
if (prefixText != "")
{
strSQLQuery = "SELECT ID," +
" stallno," +
" company " +
"FROM IESS2012_IND_PartDetails " +
"WHERE company LIKE '%" + prefixText + "%' " +
"ORDER BY company";
}
DataTable dt = objDBHelper.gReturnDataSet(System.Data.CommandType.Text, strSQLQuery).Tables[0];
List<string> items = new List<string>(count);
for (int i = 0; i < dt.Rows.Count; i++)
{
string strName = dt.Rows[i][2].ToString();
items.Add(strName);
}
if (items.ToArray().Length == 0)
{
ShowMessage();
return items.ToArray();
}
else
{
return items.ToArray();
}
}
private void ShowMessage()
{
string msg= gUserMessage.NoRecords;
return msg;
}
我將如何顯示消息,沒有記錄?
我們可以看到你說你嘗試過什麼? – 2012-01-13 11:38:38