By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,205 Members | 1,482 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,205 IT Pros & Developers. It's quick & easy.

C# Datagrid Blank

P: n/a
I created a datagrid and it worked great in the regular C#. But when I
do the exact same thing in ASP it does not work.

private void btnSignUp_Click(object sender, System.EventArgs e)
{
string connectionString="data source=JEFF-3KQH2O8TJF;initial
catalog=studyXSQL3;Integrated Security=SSPI";
SqlConnection studyXconnection=new SqlConnection(connectionString);
string selectStatement = "SELECT postID, userName, Post, Date,
Views "
//+ "ProductTotal, SalesTax, ShippingAndHandling, InvoiceTotal "
+ "FROM Posts ";
// + "WHERE CustomerID = @CustomerID "
// + "ORDER BY InvoiceID";
//studyXconnection.Open();
//SqlCommand selectCommand = new SqlCommand(selectStatement,
studyXconnection);
//selectCommand.ExecuteNonQuery();
SqlDataAdapter invoicesDataAdapter = new
SqlDataAdapter(selectStatement, studyXconnection);
DataSet invoicesDataSet = new DataSet();
invoicesDataAdapter.Fill(invoicesDataSet, "Posts");
grdPosts.AutoGenerateColumns = true;
grdPosts.DataSource = invoicesDataSet.Tables["Posts"];
invoicesDataAdapter.Update(invoicesDataSet,"Posts" );
//grdPosts.
//studyXconnection.Close();
}

May 15 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
"rex64" <st****@gmail.com> wrote in message
news:11**********************@v46g2000cwv.googlegr oups.com...
I created a datagrid and it worked great in the regular C#. But when I
do the exact same thing in ASP it does not work.

private void btnSignUp_Click(object sender, System.EventArgs e)
{
string connectionString="data source=JEFF-3KQH2O8TJF;initial
catalog=studyXSQL3;Integrated Security=SSPI";
SqlConnection studyXconnection=new SqlConnection(connectionString);
string selectStatement = "SELECT postID, userName, Post, Date,
Views "
//+ "ProductTotal, SalesTax, ShippingAndHandling, InvoiceTotal "
+ "FROM Posts ";
// + "WHERE CustomerID = @CustomerID "
// + "ORDER BY InvoiceID";
//studyXconnection.Open();
//SqlCommand selectCommand = new SqlCommand(selectStatement,
studyXconnection);
//selectCommand.ExecuteNonQuery();
SqlDataAdapter invoicesDataAdapter = new
SqlDataAdapter(selectStatement, studyXconnection);
DataSet invoicesDataSet = new DataSet();
invoicesDataAdapter.Fill(invoicesDataSet, "Posts");
grdPosts.AutoGenerateColumns = true;
grdPosts.DataSource = invoicesDataSet.Tables["Posts"];
invoicesDataAdapter.Update(invoicesDataSet,"Posts" );
//grdPosts.
//studyXconnection.Close();
}


Not sure, but I think you have to call grdPosts.DataBind() after setting
grdPosts.DataSource.

Chris Jobson
May 15 '06 #2

P: n/a
Yup, that is all it was. Thanks a million!!!!!!!! You dont know how
much time I spent trying to get this to work.

May 15 '06 #3

P: n/a
Seeing this type of code makes me wonder. I sure hope this is sample
code and not placed in production, this would be a total nightmare to
maintain if it was.

May 15 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.