|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Cant get a gridview to bind to my datasetthe 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 = ""; you must select the table to be shown.
searchResultsGridView.DataSource = ds.table("KB") rg, Eric <catro***@gmail.com> schreef in bericht Show quoteHide quote news:1134683421.534910.320530@z14g2000cwz.googlegroups.com... > 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 = ""; >
ck_Problems
Datagrid, formatting, carriage returns URGENT - ASP.NET Labels and LinkButtons behaving inconsistently ac CheckBoxList problem. Want to add some javascript to each checkbox Working, sorta...drop down list Implement form's onSubmit functionality IE Web Controls : TabStrip and Mulitpage Tab Strip soapExtensionTypes UserControl problem |
|||||||||||||||||||||||