473,387 Members | 1,536 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Data Will Not Display In Gridview

35
hi,
i need help!
i am developing a web application where the user inputs some data via
textboxes and it is saved in a database. i have written the following
code to pass the parameter values to a gridview. it generates no
errors but nothing is displayed on the gridview page. what method do i
use to save the data to the database since this does not work?

public void login1_Click(object sender, EventArgs e)
{


addstudentinfo.InsertParameters["Surname"].DefaultValue =
TextBox1.Text.ToString();
addstudentinfo.InsertParameters["Names"].DefaultValue
=
TextBox2.Text.ToString();
addstudentinfo.InsertParameters["Regno"].DefaultValue
=
TextBox3.Text.ToString();
}
Thank you
Aug 17 '07 #1
3 1977
I will like to understand what exactly you want to do
with the GridView. Do you want to display in the GridView what the
user wants to save to the Database before committing it or after committing it to
the Database?

Anyway, if you want to save to the DB firstly before binding the table to the GridView, then you can try creating a Dataset

Firstly, assuming we have a connection to a Database, save what is in your textboxes by concatenation into the sql statement within a command object just like the one below.

The lines below will execute the SelectCommand below and bind the results to
a DataGridView.

sqlDataAdapter1.SelectCommand.CommandText="SELECT * FROM titles;" ;

DataSet ds= new DataSet();

sqlDataAdapter1.Fill( ds ) ;

DataGridView1.DataSource=ds.Tables[0] ;
DataGridView1.Refresh();//Not really necessary. can remove this line.


Regards,
maleEngineer

hi,
i need help!
i am developing a web application where the user inputs some data via
textboxes and it is saved in a database. i have written the following
code to pass the parameter values to a gridview. it generates no
errors but nothing is displayed on the gridview page. what method do i
use to save the data to the database since this does not work?

public void login1_Click(object sender, EventArgs e)
{


addstudentinfo.InsertParameters["Surname"].DefaultValue =
TextBox1.Text.ToString();
addstudentinfo.InsertParameters["Names"].DefaultValue
=
TextBox2.Text.ToString();
addstudentinfo.InsertParameters["Regno"].DefaultValue
=
TextBox3.Text.ToString();
}
Thank you
Aug 17 '07 #2
mercea
35
I will like to understand what exactly you want to do
with the GridView. Do you want to display in the GridView what the
user wants to save to the Database before committing it or after committing it to
the Database?

Anyway, if you want to save to the DB firstly before binding the table to the GridView, then you can try creating a Dataset

Firstly, assuming we have a connection to a Database, save what is in your textboxes by concatenation into the sql statement within a command object just like the one below.

The lines below will execute the SelectCommand below and bind the results to
a DataGridView.

sqlDataAdapter1.SelectCommand.CommandText="SELECT * FROM titles;" ;

DataSet ds= new DataSet();

sqlDataAdapter1.Fill( ds ) ;

DataGridView1.DataSource=ds.Tables[0] ;
DataGridView1.Refresh();//Not really necessary. can remove this line.


Regards,
maleEngineer
hi, thanks for the suggestion but it didnt work. the table displays a list of students registered on the site. i'm using GRIDVIEW and not DATAVIEW as it failed me earlier.maybe the soln u suggested didnt work cos i placed it wrongly.
All the same, this are snippets of my code.

this is the code on the Gridview page:

protected void Page_Load(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection("Data Source=(local);Initial Catalog=engineering; Integrated Security=True");
SqlCommand cmnd = new SqlCommand("SELECT * FROM test101",conn);



conn.Open();

GridView1.DataSource = cmnd.ExecuteReader();

GridView1.DataBind();

conn.Close();

the code on the login page is:

public void login1_Click(object sender, EventArgs e)
{
addstudentinfo.InsertParameters["Surname"].DefaultValue =
TextBox1.Text.ToString();
addstudentinfo.InsertParameters["Names"].DefaultValue =
TextBox2.Text.ToString();
addstudentinfo.InsertParameters["Regno"].DefaultValue =
TextBox3.Text.ToString();

can u still help? thanks
Aug 17 '07 #3
Plater
7,872 Expert 4TB
You have this question here as well:
http://www.thescripts.com/forum/thread694306.html
Aug 17 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: theKirk | last post by:
using Visual Studio 2005 C# ASP.NET I know there has to be a simple way to do this....I want to use C# in a code behind for aspx. Populate a GridView from an xml file Add Fields to the...
7
by: | last post by:
Hello, Does anyone have an idea on how I can filter the data in the gridview control that was returned by an sql query? I have a gridview that works fine when I populate it with data. Now I...
5
by: sutphinwb | last post by:
Hi - This could be a simple question. When I relate two tables in a datasetet, how do I get that relation to show up in a GridView? The only way I've done it, is to create a separate table in the...
0
by: Sam | last post by:
I am fairly new to ASP. Net 2.0, background MS Access 2000/2003 and working knowledge of SQL 2000. Scenario: Page1: Blank Page loads with 2 Text Boxes (TxtLast, TxtFirst), a Command...
8
by: Greg Lyles | last post by:
Hi all, I'm trying to develop an ASP.NET 2.0 website and am running into some real problems with what I thought would be a relatively simple thing to do. In a nutshell, I'm stuck on trying to...
3
by: Mike | last post by:
I'm using the 2.0 framework and cannot get a gridview to return records with an objectDataSource. I can preview the data from the datatable. To make this as simple as possible I used the wizard...
0
by: Adam Sandler | last post by:
Hello, Prior to posting I looked at http://groups.google.com/group/ microsoft.public.dotnet.framework.aspnet/browse_thread/thread/ d8d5ae243614085e/d4fd6c4a5aa56f75 ...
4
by: Mark Olbert | last post by:
I'm running into a well-described issue in the ASPNET model that I haven't found a good work around for. I have a GridView to which I dynamically add data-bound TemplateFields at run-time. The...
0
by: jaredciagar | last post by:
Hi Guys, Can You Help Me PLease, I'm Currently facing Problems in my system... I need some help... I'm using VB script,ASP.net,MS SQL Server2005 I want to select a specific data in...
1
by: Dave | last post by:
I'm having problems getting the GridView to reliably display a large amount of data (50,000+ rows). I am working my way through the excellent book “Real World ASP.NET Best Practices” by Farhan...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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,...

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.