DataGrid OnItemDataBound problem in APS.NET C#

Discussion in 'ASP .Net' started by Steven, Jul 9, 2003.

  1. Steven

    Steven Guest

    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.
     
    Steven, Jul 9, 2003
    #1
    1. Advertising

  2. Steven

    Simon Guest

    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
     
    Simon, Jul 9, 2003
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Miguel Dias Moura

    Problem with Aps.Net 2.0 Master Page. ID's?

    Miguel Dias Moura, Mar 15, 2006, in forum: ASP .Net
    Replies:
    3
    Views:
    3,777
    Miguel Dias Moura
    Mar 15, 2006
  2. xzzy
    Replies:
    3
    Views:
    492
    Teemu Keiski
    Jun 18, 2006
  3. snt
    Replies:
    0
    Views:
    422
  4. ITnerd
    Replies:
    1
    Views:
    138
    Giorgio Parmeggiani
    Nov 2, 2003
  5. pl

    javascript problem aps.net

    pl, Oct 17, 2003, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    125
    Juan Wajnerman
    Oct 18, 2003
Loading...

Share This Page