473,748 Members | 9,933 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Displaying data in datagrid problem

Hi
I am displaying data in Datagrid in ASP.NET with
Edit/Update functionality for each row. On the same page I
have 2 Button controls which submits the request to
server. These button controls are Web Control & not HTML
control. One of these buttons whose title is Delete is
added on the aspx page in design view & also I double
clicked on this button in design view to get the onclick
code for this button in the code behind page. & for
creating the other button whose title is say SaveData I
copied the aspx syntax of the first button & also the
code behind code for Click event of this button. I have
taken care to give diferent id to both of these buttons.
Now there are 2 rows displayed in the datagrid &
both of these buttons are at the bottom. When I click on
Delete button (one which was added in design mode)
the request goes to the, server since there is no code
written in the onclick event of this button page gets
loaded with same data as it is. This is fine
But when I click on SaveData button (one which was
created by copying the aspx & aspx.cs code) request goes
to the server & even though the onclink event for
this button doesn't have any code to execute, the page
gets loaded with disturbed datagrid structure. In the page
the data is scattered because of uneven colspan for any
row gets added. I tried to debug the solution , then I
found even I am not binding any datasource in the Postback
on onclick of savedata button the ItemCreated event of the
datagrid gets fired which randomly sets any colspan to the
cells which are created, because of which I gets scattered
data when this data is rendered into the browser.
I didn't find any reason how this should happen in
Item created event.
I would be thankfull if anybody could suggest me
proper solution

Regards
Vinayak
Nov 17 '05 #1
3 4927
Hi Carl
I am binding the Dataset to datagrid in postback ==
false. And I have implemented ItemDataBound & ItemCreated
event. Since I am not binding data in the post back
ItemDataBound event does not get fired but instead
ItemCreated event get fired where it randomly puts colspan
to a row which makes the datagrid to display data in
disturbed manner. And this is happening only in click
event of SaveData button & not on click on Delete button.

Regards
Vinayak

-----Original Message-----
Vinayak,
Just a guess here (since you didn't post any code).

In the Page_Load event, do you have a "If Not Page.IsPostBack Then"around the code where you are doing the initial data binding?
Also, have you implemented any other event handlers for the DataGrid?If so, what are you doing in those events? etc...

Make sure you've installed the latest .NET Framework Service Packhttp://msdn.microsoft.com/netframewo...oads/updates/d efault.aspx
If you are still having problems, post some code which repros the problem.
--

Thanks,
Carl Prothman
Microsoft ASP.NET MVP
http://www.able-consulting.com
"vinayak" <na************ *@hotmail.com> wrote
I am displaying data in Datagrid in ASP.NET with
Edit/Update functionality for each row. On the same page I have 2 Button controls which submits the request to
server. These button controls are Web Control & not HTML
control. One of these buttons whose title is Delete is
added on the aspx page in design view & also I double
clicked on this button in design view to get the onclick
code for this button in the code behind page. & for
creating the other button whose title is say SaveData I
copied the aspx syntax of the first button & also the
code behind code for Click event of this button. I have
taken care to give diferent id to both of these buttons.
Now there are 2 rows displayed in the datagrid &
both of these buttons are at the bottom. When I click on
Delete button (one which was added in design mode)
the request goes to the, server since there is no code
written in the onclick event of this button page gets
loaded with same data as it is. This is fine
But when I click on SaveData button (one which was
created by copying the aspx & aspx.cs code) request goes
to the server & even though the onclink event for
this button doesn't have any code to execute, the page
gets loaded with disturbed datagrid structure. In the page the data is scattered because of uneven colspan for any
row gets added. I tried to debug the solution , then I
found even I am not binding any datasource in the Postback on onclick of savedata button the ItemCreated event of the datagrid gets fired which randomly sets any colspan to the cells which are created, because of which I gets scattered data when this data is rendered into the browser.
I didn't find any reason how this should happen in
Item created event.
I would be thankfull if anybody could suggest me
proper solution

Regards
Vinayak

.

Nov 17 '05 #2
Hi Carl
I got the problem. Actually in ItemDataBound event I am
modifying the Cells structure ( I am making Colspan of
some of the rows to 3 & also deleting some columns
according to my business functionality). This is working
fine if I click on Delete button because on onclick of
this button I am binding data to datagrid which makes the
proper structuring of all the cells in ItemDatabound event
& data is displayed properly in Datagrid. But when I click
on SaveData button I am not binding data to datagrid which
do not make to fire ItemDataBound event & because of which
proper structuring of data do not take place & I get
scattered data in datagrid.
Now what my problem is, I thought earlier that even if
you make changes in Cells structure of datagrid you don't
need to bind data in postback event since viewstate will
maintain the Cells structure & data. So it seems now that
this statement is wrong. Can you through a light on this
statement. I mean whether this statement is right or wrong.

Regards
Vinayak
-----Original Message-----
Vinayak,
Just a guess here (since you didn't post any code).

In the Page_Load event, do you have a "If Not Page.IsPostBack Then"around the code where you are doing the initial data binding?
Also, have you implemented any other event handlers for the DataGrid?If so, what are you doing in those events? etc...

Make sure you've installed the latest .NET Framework Service Packhttp://msdn.microsoft.com/netframewo...oads/updates/d efault.aspx
If you are still having problems, post some code which repros the problem.
--

Thanks,
Carl Prothman
Microsoft ASP.NET MVP
http://www.able-consulting.com
"vinayak" <na************ *@hotmail.com> wrote
I am displaying data in Datagrid in ASP.NET with
Edit/Update functionality for each row. On the same page I have 2 Button controls which submits the request to
server. These button controls are Web Control & not HTML
control. One of these buttons whose title is Delete is
added on the aspx page in design view & also I double
clicked on this button in design view to get the onclick
code for this button in the code behind page. & for
creating the other button whose title is say SaveData I
copied the aspx syntax of the first button & also the
code behind code for Click event of this button. I have
taken care to give diferent id to both of these buttons.
Now there are 2 rows displayed in the datagrid &
both of these buttons are at the bottom. When I click on
Delete button (one which was added in design mode)
the request goes to the, server since there is no code
written in the onclick event of this button page gets
loaded with same data as it is. This is fine
But when I click on SaveData button (one which was
created by copying the aspx & aspx.cs code) request goes
to the server & even though the onclink event for
this button doesn't have any code to execute, the page
gets loaded with disturbed datagrid structure. In the page the data is scattered because of uneven colspan for any
row gets added. I tried to debug the solution , then I
found even I am not binding any datasource in the Postback on onclick of savedata button the ItemCreated event of the datagrid gets fired which randomly sets any colspan to the cells which are created, because of which I gets scattered data when this data is rendered into the browser.
I didn't find any reason how this should happen in
Item created event.
I would be thankfull if anybody could suggest me
proper solution

Regards
Vinayak

.

Nov 17 '05 #3
"Vinayak" <na************ *@hotmail.com> wrote
I got the problem. Actually in ItemDataBound event I am
modifying the Cells structure ( I am making Colspan of
some of the rows to 3 & also deleting some columns
according to my business functionality). This is working
fine if I click on Delete button because on onclick of
this button I am binding data to datagrid which makes the
proper structuring of all the cells in ItemDatabound event
& data is displayed properly in Datagrid. But when I click
on SaveData button I am not binding data to datagrid which
do not make to fire ItemDataBound event & because of which
proper structuring of data do not take place & I get
scattered data in datagrid.

Ahhh, I figured you were doing something in one of those
DataGrid's events handlers... ;-)
Now what my problem is, I thought earlier that even if
you make changes in Cells structure of datagrid you don't
need to bind data in postback event since viewstate will
maintain the Cells structure & data. So it seems now that
this statement is wrong. Can you through a light on this
statement. I mean whether this statement is right or wrong.


Hmmm, post some same code on what you are trying to do,
and I'll take a look to see exactly what is going on.

--

Thanks,
Carl Prothman
Microsoft ASP.NET MVP
http://www.able-consulting.com


Nov 17 '05 #4

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

Similar topics

12
2450
by: Charles Astwood | last post by:
Hi, just starting out working my way round C Sharp and aspx. Used to write all my sites in asp and just need a few pointers in how to display data. I have made a connection to my SQL2000 database with SqlConnection as I think this is the fastest and best? I have also written my SELECT statement, but am confused in how to display this data not in a Table as all the examples on the web seem to want me to
3
2547
by: Diego TERCERO | last post by:
Hi... I'm working on a tool for editing text resources for a family of software product my company produces. These text resources are found in a SQL Server database, in a table called "Resource" with the following structure : Resource{,en,fr,es} Yes.. these are the only languages supported actually. A couple of rows in that table would look like this :
2
2954
by: VM | last post by:
When I display data to a Windows datagrid I usually fill the underlying table (in another class) and then, once it contains all the data, I attach it to the grid. But there are some processes that involve large amounts of data so the user won't be able to see anything in the grid until after the table's already filled up (usually 40-60 secs with these large processes). Is it possible (without changing the process of filling the table...
2
1648
by: scott | last post by:
Hi all, Iv got a slight problem with a datagrid and the ability to only display certain things in it. I have a Data grid which is connected to a data table. The data table is connected to a data set which in turn gets its info from
1
1617
by: Patrick.O.Ige | last post by:
Hello guys i made a Datagrid with Editing,Update and Cancel using VS.NET. to my surprise nothing is on the screen after compilation .. By code below:- Imports System.Data Imports System.Data.SqlClient Imports System.Web.UI.WebControls Imports System.Web.UI.HtmlControls Public Class datagrid_edit Inherits System.Web.UI.Page
2
1370
by: Fedor G via DotNetMonster.com | last post by:
Pls help me manage the data displaying on the webform aspx c# page. I used Dreamweaver to manage data displaying in the repeat table, ie simply dragged the fields to the table cells, where I need to display data. then set a repeat region for the table. Now the problem is I dont know how to put desired data to the desired places on the webform page. the data is displyed well in datagrid.
0
1589
by: Craig | last post by:
Hello, I have a web form that allows the user to move a unit on a manufacturing router. The user click one of five buttons which each represent a step on the router. When the user clicks any of the five buttons, I do a SQL select to gather some data about this unit and populate a datagrid w/ the resulting data. I want the data in the datagrid to be displayed to the user, and THEN I want to prompt the user w/ a messagebox(), that ask...
0
1514
by: latin & geek via DotNetMonster.com | last post by:
hi! ok, im working on a database application. ive successfully managed to establish a relationship between two tables and display them on a datagrid, edit and add new records to them. now i need to generate a report using the parameters in the child table, and two columns from the parent table. this is where the problem starts. when i use two seperate connection links and extract the required data, adding it all to the same dataset,...
0
2190
by: saravanaVijayakumar | last post by:
I'm new to xml .. I had created a application such a way that I have to display the xml file in treeview control in C#.Net Application ... If I select the particular Node it should display the attributes of that node in DataGrid But I am displaying the attributes in dataGrid if i use the following Code XmlNode x = root.SelectSingleNode("//JDF")
0
8991
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
8831
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
9548
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
9249
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
8244
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
6796
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
6076
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4607
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
2787
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.