,我使用datagridview
显示给用户类的细节,但我也想显示自定义的消息时,我的表中没有找到的记录,然后我想显示像 “没有记录创立”自定义消息。 这个消息应该是datagrird
视图一样,如果你熟悉asp
那里是空data template
在gridview
这里显示自定义消息是显示在我的datagridview
如何在我的窗口形式显示自定义消息在空的DataGridView
public void getData()
{
try
{
con = new SqlConnection(str);
con.Open();
string getAll = "select (CatID) as [ID],CategoryName as [Category Name] from Category order By CategoryName";
SqlCommand cmd = new SqlCommand(getAll, con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds, "Category");
dataGridView1.DataSource = ds;
dataGridView1.DataMember = ds.Tables[0].ToString();
con.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
and i called this method on form load.