473,486 Members | 2,181 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

DataGrid OnItemDataBound problem in APS.NET C#

I have 2 different data grids that are storing data from
two different tables in my data base:

My datagrid starts like this:
<asp:DataGrid id="DataGridGPA" runat="server"
OnItemDataBound="bindGPAList" ...
My bindGPAList looks like this:
public void bindGPAList(object sender,
DataGridItemEventArgs e) {
if(e.Item.ItemType == ListItemType.EditItem) {
DropDownList Dl = (DropDownList)
e.Item.FindControl("dropDownListGPASemester");
Dl.SelectedIndex = Dl.Items.IndexOf(
Dl.Items.FindByValue( DataBinder.Eval
(e.Item.DataItem, "theSemester").ToString() ) );

}
if((e.Item.ItemType == ListItemType.Item) ||
(e.Item.ItemType == ListItemType.AlternatingItem)) {

if(DataBinder.Eval
(e.Item.DataItem, "theSemester").ToString() == "1")
e.Item.Cells[0].Text = "Winter";
else if(DataBinder.Eval
(e.Item.DataItem, "theSemester").ToString() == "2")
e.Item.Cells[0].Text = "Spring";
else if(DataBinder.Eval
(e.Item.DataItem, "theSemester").ToString() == "3")
e.Item.Cells[0].Text = "Summer";
else if(DataBinder.Eval
(e.Item.DataItem, "theSemester").ToString() == "4")
e.Item.Cells[0].Text = "Fall";
}
When the page loads, Winter, Summer... semesters are
shown in the cells. Whenever someone clicks on edit or
update... in the second grid, the text Winter, Summer....
from the first datagrid cells disapears, until the user
comes back and clicks on edit link of the first. What is
causing the mysterious disapearance of the data in the
first grid column? Thank you.
Nov 17 '05 #1
1 8158
Hi Steven,

Is the EnableViewState control set to "true" ? if no, try that.
where do you bind the datagrid ? try page_load!

I hope this can help...
Simon
Nov 17 '05 #2

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

Similar topics

0
1095
by: vincent | last post by:
Hello, How do i get the last row OnItemDataBound in Datagrid or atleast the number of rows OnItemDataBound in Datagrid? thanks Vincent
0
1642
by: shamila | last post by:
</asp:label><asp:datagrid id="DataGrid3" runat="server" cssclass="DataGrid" showfooter="True" onupdatecommand="DataGrid3_Update"ondeletecommand="DataGrid3_Delete" oneditcommand="DataGrid3_Edit"...
2
3266
by: Stephen Miller | last post by:
I am using the OnItemDataBound event of Repeater control to nest a DataGrid within the Repeater. When I attempt to bind to the DataGrid using the DataSource method I get the error message "Object...
0
317
by: Curtis Hatter | last post by:
I apologize if this has been answered, but on the .NET 247 site I saw a thread titled "Datagrid's ItemCommand Event", and had similar troubles with the Datagrid not properly firing the delete event...
7
1981
by: Scott Schluer | last post by:
Hi All, I have a functioning datagrid on "Page 1" that displays order information for a single order (this is for an e-commerce site). It's actually a combination of a couple datagrids to...
4
3474
by: tshad | last post by:
I am having trouble with links in my DataGrid. I have Links all over my page set to smaller and they are consistant all over the page in both Mozilla and IE, except for the DataGrid. Here is a...
4
4068
by: david | last post by:
I have datasource, say, ds which is bounded to a datagrid, dg. Assume that ds have 5 columns, c0,c1,c2,c3,c4. In some case, say, case 1, I want to display columns c0, c1,c2 in dg and use c3 and c4...
4
1758
by: Newbie | last post by:
Hi Everyone, ASP.NET 1.x I have a problemette ! I have a datagrid on my web form. When the user hits the enter key whilst any editable field on the form including those in the datagrid...
0
1674
by: Chris | last post by:
I've been searching all over and think I am close, but keep getting the error "Index out of range" when trying to reference a nested datagrid when an OnEditCommand event is raised. When the...
0
7105
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,...
0
6967
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
7132
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,...
0
7180
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...
1
6846
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...
1
4870
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...
0
3076
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...
0
3071
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
266
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...

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.