Forums

Unbound Grid

Last post 9/6/2010 7:36 PM by Guillermo Ochoa. 3 replies.
Sort Posts: Previous Next
  • Mark Rodrigues

    Unbound Grid

    1/4/2010 11:18 AM
    • Not Ranked
    • Joined on 11/22/2009
    • Posts 6

    I am working on an application process. There is an application and on it there are courses. On my submit application page I have a grid which is not bound to a sql data source. When i click submit application, I insert a master record for the application and I want to loop through the grid rows and get the course information. I would like to use a grid not bound to a sql data source and use the built in editforms (i know how to override row inserting and row updating). Now, I have no problems doing all of these functions with a sqldatasource bound grid. But I want to use this grid to display data which has not yet hit the database. What is the best way to go about this..I just need a push in the right direction.

    So far ive tried:

    Grid bound to a datatable
    Datatable persists in viewstate
    EnableCallbacks on grid set to false

    This works, however, by setting EnableCallbacks to false, the edit forms dont persist data.
    And if i set EnableCallbacks to true, I can't update the ViewState datatable (Cant update viewstate on callback, I read this somewhere on the forum)
    (I am using the Row_Validating event and setting e.RowError to an error message if validation fails)

    Please advise.

    -Mark

  • Mark Rodrigues

    Re: Unbound Grid

    1/4/2010 1:40 PM
    • Not Ranked
    • Joined on 11/22/2009
    • Posts 6

    I am now binding to a binding list. And i can keep enable callbacks set to true. Im trying to use session to store the list.

    //IN PAGE LOAD

    if (Session["courseList"] == null)
                lst = new BindingList<IndApplicationCourseGuid>();
     else
                lst = (BindingList<IndApplicationCourseGuid>)Session["courseList"];
     dvCourses.DataSource = lst;
     dvCourses.DataBind();

    Sometimes i get the above error: Unable to cast object of type 'System.ComponentModel.BindingList`1[IndApplicationCourseGuid]' to type 'System.ComponentModel.BindingList`1[IndApplicationCourseGuid]'.

    I know this isnt the controls fault, and something on the server must be going wrong. But is there anyway I can get the control to persist my lst object between callbacks/postbacks so that I don't have to lookup session and cast?

    -Mark

  • Mark Rodrigues

    Re: Unbound Grid

    1/4/2010 4:51 PM
    • Not Ranked
    • Joined on 11/22/2009
    • Posts 6

    Ok. I have the grid being bound properly and the inserts/deleting working. However when i try to update I get:

    Multiple controls with the same ID 'DXDataRow0' were found. FindControl requires that controls have unique IDs

    I've heard this can be caused by a KeyFieldName column having multiple values, but this happens when I have only 1 row.

    Here is my INSERT code:

    IndApplicationCourseGuid course = new IndApplicationCourseGuid();
    course.Guid = Guid.NewGuid();
    course.Name = courseName.Text;
    course.Coursestartdate = startDate.Date;
    course.Courseenddate = endDate.Date;
    course.Fee = Convert.ToDouble(courseFee.Text);
    lst.Add(course);
    Session["courseList"] = lst;
    BindGrid();
    grid.CancelEdit();

     

      private void BindGrid(){
            if (Session["courseList"] == null)
                lst = new BindingList<IndApplicationCourseGuid>();
            else
                lst = (BindingList<IndApplicationCourseGuid>)Session["courseList"];
            dvCourses.DataSource = lst;
            dvCourses.KeyFieldName = "Guid";
            dvCourses.DataBind();
        }


    //ASPX

     <dxwgv:ASPxGridView ID="dvCourses" runat="server" KeyFieldName="Guid"
            CssFilePath="~/App_Themes/Aqua/{0}/styles.css" CssPostfix="Aqua"
            Width="100%" AutoGenerateColumns="False" onrowdeleting="dvCourses_RowDeleting1"
                    onrowinserting="dvCourses_RowInserting1"
                    onrowvalidating="dvCourses_RowValidating1"
                    onhtmlrowcreated="dvCourses_HtmlRowCreated"
                    onrowupdating="dvCourses_RowUpdating1">
            <Columns>
            <dxwgv:GridViewCommandColumn Name="colCommands" VisibleIndex="0">
            <NewButton Visible="true"></NewButton>
            <EditButton Visible="true"></EditButton>
            <DeleteButton Visible="true"></DeleteButton>
            </dxwgv:GridViewCommandColumn>
            <dxwgv:GridViewDataTextColumn Name="Guid" FieldName="Guid">
            </dxwgv:GridViewDataTextColumn>
              <dxwgv:GridViewDataTextColumn Name="colCourseName" FieldName="Name" Caption="Course Name" VisibleIndex="1">
                </dxwgv:GridViewDataTextColumn>
                <dxwgv:GridViewDataTextColumn Name="colStartDate" FieldName="Coursestartdate" Caption="Start Date" VisibleIndex="3" PropertiesTextEdit-DisplayFormatString="d">
                    <PropertiesTextEdit DisplayFormatString="d">
                    </PropertiesTextEdit>
                </dxwgv:GridViewDataTextColumn>
                <dxwgv:GridViewDataTextColumn Name="colEndDate" FieldName="Courseenddate" Caption="End Date" VisibleIndex="4" PropertiesTextEdit-DisplayFormatString="d">
                    <PropertiesTextEdit DisplayFormatString="d">
                    </PropertiesTextEdit>
                </dxwgv:GridViewDataTextColumn>
                <dxwgv:GridViewDataTextColumn Name="colFee" FieldName="Fee" Caption="Fee" VisibleIndex="5">
                    <PropertiesTextEdit DisplayFormatString="C">
                    </PropertiesTextEdit>
                </dxwgv:GridViewDataTextColumn> 
            </Columns>

    I'm clueless as to why this is happening, and an answer to this would help me finish this module.
    Slowly, but surely. Any help would be greatly appreciated.

    -Mark

  • Guillermo Ochoa

    Re: Unbound Grid

    9/6/2010 7:36 PM
    • Not Ranked
    • Joined on 11/13/2009
    • Posts 10

    Hello there Mark, 

    Did you find a solution? 

     

    We have a similar situation,

    Thank u in advance!

     

    Regards

More from DevExpress
Live Chat
Have a pre-sales question?
Need assistance with your evaluation?
We are here to help.
Chat is one of the many ways you can contact members of the DevExpress Team. We are available Monday-Friday between 8:30am and 5:00pm Pacific Time.
If you need additional product information, require pre-sales assistance, or want help with your order, write to us at info@devexpress.com or call us at
+1 (818) 844-3383.