473,659 Members | 2,626 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DataGrid does not display?

I placed a datagrid on my webform, set the datasource to a datareader, and
bound the reader to the datagrid. However, my datagrid does not display.
Here is my code from the Page_Load method:

=============== =============== ======
dgAgmtList = new DataGrid();
SqlConnection con;
string sql;
SqlCommand cmd;
SqlDataReader reader;

sql = "SELECT * FROM [User] WHERE user_id='" + Page.User.Ident ity.Name +
"'";
con = new
SqlConnection(C onfigurationSet tings.AppSettin gs["OFS.Connection String"]);
cmd = new SqlCommand(sql, con);
con.Open();
reader = cmd.ExecuteRead er(CommandBehav ior.CloseConnec tion);

int rowcount = 0;
if (reader.HasRows )
{
while(reader.Re ad())
{ rowcount++; }
}

if (rowcount == 0)
{
reader.Close();
Server.Transfer ("nextpage.aspx ");
}
else
{
dgAgmtList.Data Source = reader;
dgAgmtList.Data Bind();
reader.Close();
}
Nov 18 '05 #1
1 1226
Set the datagrid.dataso urce =
cmd.ExecuteRead er(CommandBehav ior.CloseConnec tion);
"Mervin Williams" <mw*******@inno vasolutions.net > wrote in message
news:uT******** ******@tk2msftn gp13.phx.gbl...
I placed a datagrid on my webform, set the datasource to a datareader, and
bound the reader to the datagrid. However, my datagrid does not display.
Here is my code from the Page_Load method:

=============== =============== ======
dgAgmtList = new DataGrid();
SqlConnection con;
string sql;
SqlCommand cmd;
SqlDataReader reader;

sql = "SELECT * FROM [User] WHERE user_id='" + Page.User.Ident ity.Name +
"'";
con = new
SqlConnection(C onfigurationSet tings.AppSettin gs["OFS.Connection String"]);
cmd = new SqlCommand(sql, con);
con.Open();
reader = cmd.ExecuteRead er(CommandBehav ior.CloseConnec tion);

int rowcount = 0;
if (reader.HasRows )
{
while(reader.Re ad())
{ rowcount++; }
}

if (rowcount == 0)
{
reader.Close();
Server.Transfer ("nextpage.aspx ");
}
else
{
dgAgmtList.Data Source = reader;
dgAgmtList.Data Bind();
reader.Close();
}

Nov 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1670
by: Frnak McKenney | last post by:
I have a (small) multi-table database application which allows edits, print reports, and has two scrolling screen displays which show information merged from multiple tables. I'm having trouble with one of the scrolling displays which is implemented as a DataGrid with several custom DataGridColumnStyles. When the Form containing the DataGrid is made visible the initial rows of the DataGrid's DataView source display as one might expect....
5
4440
by: Bill Todd | last post by:
In a WinForms application with a DataGrid bound to a DataTable, if I change the DefaultDataView.Sort property the order of the data in the grid does not change. If I change the Sort property then reassign the DataTable to the DataGrid's DataSource the DataGrid does show the new order. If I change the Sort property then call DataGrid.SetDataBinding the DataGrid does _not_ show the new order.
5
5530
by: Jim | last post by:
is it possible to add a row to a Windows datagrid witthout having a datatable? I need to add a row to the datagrid control. Thanks.
5
12229
by: John Richardson | last post by:
I've been bothered for some time about my DataGrid not populating my rows very quickly. I have about 10K rows loading into the grid. I create a datatable dt with 2 columns, an ID and a display. The ID is a member of the keys array. I then create a DataView dv over the table, and sort it by Display and ID column (in case of duplicate Display). I then set my DataGrid.DataSource = dv; I then load the datatable with my rows, and this is...
2
1220
by: Mervin Williams | last post by:
I just discovered that the datagrid does not display if the webform is in new mode. Let's say, for instance, that my datagrid is for contacts related to a company, so that companyid id a foreign key in the contact table. Well, if the contact does not yet exist, the datagrid will not display. I would like the datagrid to display the footer (which I've set up to insert new rows into the datagrid), although perhaps disabled. Is there a...
12
1997
by: Daniel Walzenbach | last post by:
Hi, I want to display a Label in a DataGrid according to some condition. I therefore check whether the condition is true in the ItemDateBound EventHandler of the DataGrid. Unfortunately the conversion is extremely costly in performance. Does anybody know how I could set the label (of the whole content of the TableCell) to .Visible = False without converting e.Item.Controls(2) to a System.Web.UI.WebControls.Label?
7
1804
by: Bart Schelkens | last post by:
Hi, I have 2 more questions : 1. Can I fill a datagrid by using a DataReader or does it have to be a DataSet or a DataView? 2. In my datagrid I need to display two images and one of does images has te be a link to a new page. How would you do that ?
1
2551
by: Jay | last post by:
I'm wondering if anyone has even encountered a control or other scripting that will automatically rotate the rows of a datagrid... I am in the process of building an asp.net application that will display statistics on a large LCD display for viewing by people within the room (30 feet away). One problem is that the screen can obviously only display so much legible data at a time. I may have upwards of 60 or 70 rows to display on a rotating...
1
1993
by: .Net Sports | last post by:
the below itemdatabound function works , displays all the grand totals in the footer control of the datagrid: private void dglvboard_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e) { DataRowView rowData; decimal price; decimal priceWk; decimal newssum;
5
2896
by: rn5a | last post by:
In my application, I want to populate all the directories & files existing in a directory on the server in a DataGrid. To ensure that all the directories get listed first followed by all the files, I am appending all the directories with 0 & all the files with 1. Moreover, each directory & file listed in the DataGrid will have a corresponding CheckBox. To differentiate between directories & files, I am adding the string "*D" (without the...
0
8428
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
8851
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
8629
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7360
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
6181
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
4176
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...
0
4338
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1982
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1739
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.