私は数時間働いているという状況があります - ここには本当に明白な何かがあるように感じますが、私はそれを見逃しています. 私はこれほど抽象化された開発環境で働いたことがないので、それがその一部であると確信しています。どんな支援/アドバイスも大歓迎です。
製品: Web アプリ
環境:
~データベース/バックエンド; SQL Server Management Studio、SQL Server 2008 R2
~インターフェイス/フロント エンド; ASPX ページ、SharePoint 2010
〜言語、開発; Visual Studio 2010、VB.Net、JavaScript、HTML、SQL、Ajax、jQuery
〜その他; Web パーツ、更新パネルなど
タスクと問題:
組織名を含む組織コードを表示する aspx.cs のテキスト ボックスのコードを更新します (現在は名前のみを表示します)。テキストボックスには現在、組織名が表示されています。このコードは、必要な列とデータを渡す SQL Server からストアド プロシージャを呼び出します。
これまでのところ、コードを更新して、組織コードまたは組織の名前を入力し始めると、組織のリストがドロップダウン形式で表示されるようになりました。組織コードまたは名前が使用されているかどうかにかかわらず、リストと結果の選択には組織名のみが表示されます。組織コードと名前を表示するために必要です。
これまでのコードは次のとおりです。
using System;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Text;
using System.Data.SqlClient;
using System.Collections.Generic;
using IDE_Utility.DBConnection;
namespace ORG40.Layouts.ORG40
{
public partial class OrganizationSearch : LayoutsPageBase
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void GetCompleteList(object sender, EventArgs e)
{
DataSet DS = new DataSet();
SqlParameter sqlParamComp = new SqlParameter();
sqlParamComp.ParameterName = "@oName";
sqlParamComp.DbType = DbType.String;
sqlParamComp.Value = "%" + OrganizationName.Text + "%";
SqlParameter[] sqlParams = new SqlParameter[]{
new SqlParameter("@orgCode", DBNull.Value),
sqlParamComp
};
DS = DBConnection.GetDataSet("getL_Organization", CommandType.StoredProcedure, sqlParams);
GridView1.DataSource = DS;
GridView1.DataBind();
}
[System.Web.Script.Services.ScriptMethod()]
[System.Web.Services.WebMethod]
public static string[] getNames(string prefixText, int count)
{
DataSet DS = new DataSet();
SqlParameter sqlParamComp = new SqlParameter();
sqlParamComp.ParameterName = "@oName";
sqlParamComp.DbType = DbType.String;
sqlParamComp.Value = "%" + prefixText + "%";
SqlParameter[] sqlParams = new SqlParameter[]{
new SqlParameter("@orgCode", DBNull.Value),
sqlParamComp
};
DS = DBConnection.GetDataSet("getL_Organization", CommandType.StoredProcedure, sqlParams);
DataTable Dt = new DataTable();
Dt = DS.Tables[0].DefaultView.ToTable(true, new string[] {"OrgCode", "Name"});
DataRow[] Dr = new DataRow[Dt.Rows.Count];
Dt.Rows.CopyTo(Dr, 0);
return Array.ConvertAll(Dr, new Converter<DataRow, String>(DataRowToString));
}
public static string DataRowToString(DataRow pDr)
{
return Convert.ToString(pDr["OrgCode" "Name"].ToString());
}
}
}
答えは次の行の間にあるように感じます。
Dt = DS.Tables[0].DefaultView.ToTable(true, new string[] {"OrgCode", "Name"});
配列から次の行を返します。
return Convert.ToString(pDr["OrgCode" "Name"].ToString());
私の問題は、その最後の行から組織コードを表示しようとしていることにあると思います。「名前」だけを使用すると機能しますが、変更するたびにテキストボックスに何も表示されないか、コードにエラーがあります。
私の最近の考えは、コードの最後の行に関するものです -return Convert.ToString(pDr["OrgCode" "Name"]
が間違った構文であることを認識しています["OrgCode" "Name"]
.
そこに何か考えやアイデアがあれば、私は最も感謝しています。
ありがとう!