Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Cant get a gridview to bind to my dataset

Reply
Thread Tools

Cant get a gridview to bind to my dataset

 
 
catronro@gmail.com
Guest
Posts: n/a
 
      12-15-2005
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 = "";

 
Reply With Quote
 
 
 
 
Eric
Guest
Posts: n/a
 
      12-17-2005
you must select the table to be shown.

searchResultsGridView.DataSource = ds.table("KB")

rg,
Eric


<(E-Mail Removed)> schreef in bericht
news:(E-Mail Removed) oups.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 = "";
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
confused by boost::bind & boost::lambda::bind XHengDF@gmail.com C++ 0 05-29-2007 04:37 AM
cant compile on linux system.cant compile on cant compile onlinux system. Nagaraj C++ 1 03-01-2007 11:18 AM
Using a data-bind dropdownlist to populate another data-bind dropdownlist mr2_93 ASP .Net 1 10-02-2005 05:07 PM
man i cant belive i cant get help please unclejesse01 DVD Video 2 04-14-2005 03:15 PM
Cant Bind a data from a multi-table Inner Join using C# Gareth Stretch ASP .Net 0 06-26-2003 12:59 PM



Advertisments