내가 가지고있는 Topic
드롭 다운리스트를 채우고 캐시 테이블에 저장합니다 다음 코드를다른 선택에 따라 하나의 드롭 다운리스트를 필터링하는 방법
bookingData2 = new DataTable();
DataTable DTable_List = new DataTable();
string connString = @"";
string query2 = @"Select * from [DB].dbo.[top]";// columng #1 = Specialty and column #2 = Topic
using (SqlConnection conn = new SqlConnection(connString))
{
try
{
SqlCommand cmd = new SqlCommand(query2, conn);
SqlDataAdapter da = new SqlDataAdapter(query2, conn);
da.Fill(bookingData2);
HttpContext.Current.Cache["cachedtable2"] = bookingData2;
bookingData2.DefaultView.Sort = "Topic ASC";
Topic.DataSource = bookingData2.DefaultView.ToTable(true, "Topic"); // populate only with the Topic column
Topic.DataTextField = "Topic";
Topic.DataValueField = "Topic";
Topic.DataBind();
Topic.Items.Insert(0, new ListItem("All Topics", "All Topics"));
da.Dispose();
}
catch (Exception ex)
{
string error = ex.Message;
}
}
내가 가지고있는 Specialty
드롭 다운리스트를 채우고 저장합니다 다음 코드 또 다른 캐시 테이블 :
bookingData = new DataTable();
DataTable DTable_List = new DataTable();
string connString = @"";
string query = @"select * from [DB].dbo.[SP]";
using (SqlConnection conn = new SqlConnection(connString))
{
try
{
SqlCommand cmd = new SqlCommand(query, conn);
SqlDataAdapter da = new SqlDataAdapter(query, conn);
da.Fill(bookingData);
bookingData.DefaultView.Sort = "Specialty ASC";
Specialty.DataSource = bookingData.DefaultView.ToTable(true, "Specialty");
Specialty.DataTextField = "Specialty";
Specialty.DataValueField = "Specialty";
Specialty.DataBind();
Specialty.Items.Remove("All Specialties");
Specialty.Items.Insert(0, new ListItem("All Specialties", "All Specialties"));
da.Dispose();
}
catch (Exception ex)
{
string error = ex.Message;
}
}
어떻게 다음을 수행하고 빠른 액세스를위한 캐시 테이블에 저장하는 Specialty
드롭 다운리스트의 인덱스 변화를 코딩 할 수 있습니다 :
protected void Specialty_SelectedIndexChanged(object sender, EventArgs e)
{
//re-populate the Topic dropdownlist to display all the topics based on the following criteria:
--> Where the Specialty column is either "All Specialties" OR "{specialty selected index value}"
}
당신이 주제와 특수 DropDownLists를 채우는 데 사용하는 방법은 무엇입니까? Page_Load? 그리고 캐싱을 사용하지 않고 DataTable을 사용하고 있습니다. – Sam
@Sam yea 처음 두 부분이 페이지로드시 실행됩니다. 전문 드롭 다운을 변경하면 두 가지 옵션을 토픽으로 업데이트하고 싶습니다. – SearchForKnowledge