C
catronro
ok i am trying to pull a dataset back from my database and then have
the searchResultsGridView diplay them. As i step through it the dataset
is being populated but never displayed by the grid view. Any ideas
message.Text = "";
SqlConnection cn = new SqlConnection();
SqlDataAdapter da = new SqlDataAdapter();
DataSet ds = new DataSet();
String sql = "";
cn.ConnectionString = "Data Source=example;Initial
Catalog=KnowledgeBase;Persist Security Info=True;User
ID=someone;Password=";
sql = "SELECT KBID, Topic, AppliesTo, LastModified FROM KB
WHERE Approved = '1' and IsPayrollExport = '1' and Topic LIKE
'%@Topic2%' ORDER BY Topic";
da.SelectCommand = new SqlCommand(sql, cn);
da.SelectCommand.Parameters.Add("@Topic2",
SqlDbType.VarChar).Value = txtBoxSearch.Text;
da.Fill(ds);
//if (ds.Tables[0].Rows.Count > 0)
// {
searchResultsGridView.DataSource = ds;
searchResultsGridView.DataBind();
//}
// else
// {
// message.Text = "No Articles matching your criteria
could be found. Please try your search agian.";
// }
// message.Text = "";
the searchResultsGridView diplay them. As i step through it the dataset
is being populated but never displayed by the grid view. Any ideas
message.Text = "";
SqlConnection cn = new SqlConnection();
SqlDataAdapter da = new SqlDataAdapter();
DataSet ds = new DataSet();
String sql = "";
cn.ConnectionString = "Data Source=example;Initial
Catalog=KnowledgeBase;Persist Security Info=True;User
ID=someone;Password=";
sql = "SELECT KBID, Topic, AppliesTo, LastModified FROM KB
WHERE Approved = '1' and IsPayrollExport = '1' and Topic LIKE
'%@Topic2%' ORDER BY Topic";
da.SelectCommand = new SqlCommand(sql, cn);
da.SelectCommand.Parameters.Add("@Topic2",
SqlDbType.VarChar).Value = txtBoxSearch.Text;
da.Fill(ds);
//if (ds.Tables[0].Rows.Count > 0)
// {
searchResultsGridView.DataSource = ds;
searchResultsGridView.DataBind();
//}
// else
// {
// message.Text = "No Articles matching your criteria
could be found. Please try your search agian.";
// }
// message.Text = "";