DataGrid OnItemDataBound problem in APS.NET C#

S

Steven

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.
 
S

Simon

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,810
Latest member
Kassie0918

Latest Threads

Top