죄송합니다, 이것은 약간의 멍청한 질문입니다.하지만 각 gridview가 데이터베이스의 다른 테이블에 액세스하는 경우 각 gridview에 대해 별도의 데이터 소스가 필요합니까?ASP.NET C# - 동일한 데이터베이스에있는 서로 다른 테이블의 각 그리드 뷰에 대해 별도의 데이터 소스가 필요합니까?
예 : ZipCode, PlanCode 및 주어진 ZipCode, PlanCode 및 Age, 3) 주어진 상태 코드 및 이동 통신사 코드에 대해 1) 지정된 ZipCode 및 PlanCode에 대한 검색을 실행하는 3 가지 그리드 뷰가 있습니다.
다음은 C#을 코드 숨김입니다 :
protected void Search_Zip_Plan_Age_Button_Click(object sender, EventArgs e)
{
var _with1 = this.ZipPlan_SqlDataSource;
_with1.SelectParameters.Clear();
string ConnectionString = System.Configuration.ConfigurationManager.AppSettings["PriceFinderConnectionString"]
_with1.SelectCommand = "ssp_get_zipcode_plan";
_with1.SelectParameters.Add("ZipCode", this.ZipCode.Text);
_with1.SelectParameters.Add("PlanCode", this.PlanCode.Text);
_with1.SelectParameters.Add("Age", this.Age.Text);
_with1.SelectCommandType = SqlDataSourceCommandType.StoredProcedure;
_with1.CancelSelectOnNullParameter = false;
Search_Results_GridView.DataBind();
}
감사합니다!
또한 데이터 소스 컨트롤을 모두 사용하지 않고 수동 바인딩을 수행하지 않아도됩니다. 일반적으로 데이터 액세스 레이어를 작성한 다음 컨트롤에 바인딩하는 데 필요한 데이터의 다양한 뷰를 반환하는 함수를 노출합니다. –
@FrankHale, 응답 해 주셔서 감사합니다. 해당 메서드 및 dll 파일과 함께 저장 프로 시저를 사용합니까? 시간이 있으면 모든 파일에 필요한 코딩 예를 답으로 보내주십시오. System.Configuration.ConfigurationManager.AppSettings 오류에 대한 아이디어가 있습니까? –
.ToString 호출 후 put()을 시도하십시오. ConfigurationManager 행에서 오는 오류를 지우는 지 확인하십시오. –