首先,我認爲你需要在你的SQL語句
SELECT * FROM
Document INNER JOIN Registration
ON Document.DocNo=Registration.DocNo
Where [email protected]
下一個內部聯接,如果你正在使用ADO.NET來解釋,你可能會想要的數據類專業類將數據存儲像
public class DocumentRegistration
{
public int DocNo {get; set;}
public string DocType {get; set;}
public string DocTitle {get; set;}
public int RegNo {get; set;}
public DateTime RedDate {get; set;}
public string Location {get; set;}
}
接下來,您可以使用ADO.NET數據進入你的類
List<DocumentRegistration> list= new List<DocumentRegistration>();
SqlConnection conn = new SqlConnection();
conn.ConnectionString="YourConnectionString"
conn.Open();
SqlCommand cmd = new SqlCommand("Show_Data_ByTitle", conn);
SqlCommand cmd = System.Data.CommandType.StoredProcedure;
cmd.Parameters.Add(new SqlParameter("Title", "yourtitle"));
SqlReader reader = cmd.ExecuteReader();
while(reader.Read())
{
DocumentRegistration dr=new DocumentRegistration
{
DocNo = Convert.ToInt32(reader["DocId"]);
DocType = Convert.ToString(reader["DocType"]);
DocTitle = Convert.ToString(reader["DocTitle"]);
RedDate = Convert.ToDateTime(reader["RedDate"]);
}
list.Add(dr);
}
//put this code where you want to load the list like PageLoad()
GridView1.DataSource=list;
GridView1.Databind();
希望這會有所幫助
從哪張表格中顯示網格視圖,文檔或註冊數據? – Kuldeep
他們兩個,在2個網格 – AComputer