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();
} 3 1356
"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
Yup, that is all it was. Thanks a million!!!!!!!! You dont know how
much time I spent trying to get this to work.
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. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: K |
last post by:
I created a collection which is derived from ArrayList and implements
IBindingList and ITypedList.
Then I bound the DataSource of a data grid into the collection. It could
show up the data but...
|
by: Junkguy |
last post by:
I need to be able to tell if the blank row of a DataGrid has been edited or
not.
In a DataGrid, you may notice that if you click on the asterisk row, the
asterisk will change to a triangle, but...
|
by: Junkguy |
last post by:
Does anyone know the best way to put the cursor in the "blank" row of an
editable datagrid when it is initially displalyed?
I need to present the user with a list of rows from a dataset, but I...
|
by: Robert Schuldenfrei |
last post by:
Dear NG,
After being away from C# programming for a spell, I am trying my hand at
what should be a simple task. I have been hitting my head against the wall
this morning. I have a simple order...
|
by: MrMike |
last post by:
Is it possible to specify (or somehow set) the amount of space between each
datagrid row without changing the amount of space between datagrid columns?
I have a datagrid displaying data which...
| |
by: Dan11 |
last post by:
here's C sharp code:
Start code...
private void searchBtn_Click(object sender, System.EventArgs e)
{
//For sqlCommand1 is a search by Wkst ID (employeeID on pubs) params
if...
|
by: Lyners |
last post by:
I have a web page writen in ASP.NET that contains some javascript so that
when a user presses a button, or edits a certain field in a datagrid, another
cell in the datagrid is filled with a value....
|
by: Aaron Smith |
last post by:
If I have a datagrid and the bound data file only have 4 rows in it, the
grid will show the 4 rows. However, there is blank space below that
until it reaches the bottom of the grid. Is there a way...
|
by: mfahnestock |
last post by:
Hi all!
Aspiring VB programmer losing hair <And Sleep> over this problem. I
have spent several days researching through the various usenets and
resources to no avail, and so now I am taking the...
|
by: Brian Tkatch |
last post by:
I have a form with two DataGrids, which are kept in sync manually via
Stored PROCEDURE calls. That is, when a record is selected on the first
grid, a stored PROCEDURE is CALLed to Fill() the next...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |