다른 GridView1 내에 GridView2가 있습니다. 아래 코드로 채우려고합니다. GridView4는 다른 gridview 내에 중첩되어 있지 않은지 테스트하기 위해 사용하고있는 gridview입니다. 문제없이 채워집니다. 부모의 gridview의 각 행이 중첩의 GridView에 연결되어있는 경우Gridview 내에서 Gridview 바인딩
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
foreach (GridViewRow gvr in GridView1.Rows)
{
string connectionString = "Data Source=MyConnection String";
using (SqlConnection test = new SqlConnection(connectionString))
{
test.Open();
SqlCommand cmd = new SqlCommand("SELECT [ID], [CTNum], [PRPNum], [DateEntered], [CurrentRFBDate], [CurrentRFBPRPDate], [CurrentRFPDate], [CurrentRFPPRPDate], [EnteredBy] FROM [PRPDateTracking]", test);
SqlDataReader reader = cmd.ExecuteReader();
if (reader.HasRows)
{
GridView4.DataSource = reader;
GridView4.DataBind();
((GridView)gvr.FindControl("GridView2")).DataSource = reader;
((GridView)gvr.FindControl("GridView2")).DataBind();
}
}
}
}
에 오신 것을 환영합니다에 대한 좋은 아이디어를 얻을 이러한 링크를 참조하십시오! 나는 당신의 제목을 편집했습니다. "질문에"제목에 "꼬리표"를 포함시켜야합니까? ", 여기서 합의는"아니오,하지 말아야합니다 "입니다. http://meta.stackexchange.com/questions/19190/should-questions-include-tags-in-their-titles –