473,665 Members | 2,740 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

C# Datagrid Blank

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.EventArg s e)
{
string connectionStrin g="data source=JEFF-3KQH2O8TJF;init ial
catalog=studyXS QL3;Integrated Security=SSPI";
SqlConnection studyXconnectio n=new SqlConnection(c onnectionString );
string selectStatement = "SELECT postID, userName, Post, Date,
Views "
//+ "ProductTot al, SalesTax, ShippingAndHand ling, InvoiceTotal "
+ "FROM Posts ";
// + "WHERE CustomerID = @CustomerID "
// + "ORDER BY InvoiceID";
//studyXconnectio n.Open();
//SqlCommand selectCommand = new SqlCommand(sele ctStatement,
studyXconnectio n);
//selectCommand.E xecuteNonQuery( );
SqlDataAdapter invoicesDataAda pter = new
SqlDataAdapter( selectStatement , studyXconnectio n);
DataSet invoicesDataSet = new DataSet();
invoicesDataAda pter.Fill(invoi cesDataSet, "Posts");
grdPosts.AutoGe nerateColumns = true;
grdPosts.DataSo urce = invoicesDataSet .Tables["Posts"];
invoicesDataAda pter.Update(inv oicesDataSet,"P osts");
//grdPosts.
//studyXconnectio n.Close();
}

May 15 '06 #1
3 1360
"rex64" <st****@gmail.c om> wrote in message
news:11******** **************@ v46g2000cwv.goo glegroups.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.EventArg s e)
{
string connectionStrin g="data source=JEFF-3KQH2O8TJF;init ial
catalog=studyXS QL3;Integrated Security=SSPI";
SqlConnection studyXconnectio n=new SqlConnection(c onnectionString );
string selectStatement = "SELECT postID, userName, Post, Date,
Views "
//+ "ProductTot al, SalesTax, ShippingAndHand ling, InvoiceTotal "
+ "FROM Posts ";
// + "WHERE CustomerID = @CustomerID "
// + "ORDER BY InvoiceID";
//studyXconnectio n.Open();
//SqlCommand selectCommand = new SqlCommand(sele ctStatement,
studyXconnectio n);
//selectCommand.E xecuteNonQuery( );
SqlDataAdapter invoicesDataAda pter = new
SqlDataAdapter( selectStatement , studyXconnectio n);
DataSet invoicesDataSet = new DataSet();
invoicesDataAda pter.Fill(invoi cesDataSet, "Posts");
grdPosts.AutoGe nerateColumns = true;
grdPosts.DataSo urce = invoicesDataSet .Tables["Posts"];
invoicesDataAda pter.Update(inv oicesDataSet,"P osts");
//grdPosts.
//studyXconnectio n.Close();
}


Not sure, but I think you have to call grdPosts.DataBi nd() after setting
grdPosts.DataSo urce.

Chris Jobson
May 15 '06 #2
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
2527
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 the column heading is not in the right order, for eg. I want "ID" column to be the first column but it showed as the second column. Another problem is that anyway i can leave a blank row in the grid to add a new row automatically if the user...
0
1268
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 no "new" blank asterisked row will be added to the bottom *until* you type some data. How can I tell if you have begun to type data into this row or not? Here is the reason I need this. I need to call CurrencyManager.EndCurrentEdit() on a row...
3
1780
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 want to put the cursor in the first cell of the blank row so they can begin adding data immediately instead of scrolling to the bottom. Thanks in advance. --
6
3236
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 entry application. The code below gets line items from a SQL Server database and returns them to a datagrid by way of a DataTable called lineTable. As long as I am just displaying columns in the SQL database everything works well. I now want...
4
1372
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 needs to print on specially-sized labels. In order to accurately print one-datagrid row-per-label, I need to somehow set 2-inches of blank space between each row. CellPadding and CellSpacing settings affect the amount of space between columns, as...
1
1220
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 (txtEmployeeID.Text.Length > 0) {
13
2644
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. My probelm.... when I have the user press the update button (which does a post back that loops through the datagrid and updates a database) the field/cell that is filled by the javascript appears to be blank in my update code, even though I can...
10
8118
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 to have a fixed number of rows regardless of what data is in the bound table? Thanks, Aaron -- --- Aaron Smith
9
9764
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 next step. Situation: I have a form (Form 1) with a datagrid that has a context menu for adding updated records. When selecting the "Add Option" a second form (Form 2) is displayed for data population. The user saves the
3
2708
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 second DataGrid's DataSource. All that works very well. And, when there are no records to display, it is simply left blank. My issue is that when i scroll the first one, sometimes the second grid shows a bunch of null values (a "new" record). ...
0
8438
marktang
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8348
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8863
Oralloy
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8779
jinu1996
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8549
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7376
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6187
isladogs
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4186
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
1761
bsmnconsultancy
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.