Loading controls in Datagrid

Discussion in 'ASP .Net Web Controls' started by Harish, Oct 23, 2003.

  1. Harish

    Harish Guest

    Dear All,

    I am being assigned a task of developing a .NET web application from
    an existing client server(CS) application (VB). It is a requirement
    that much of the things should look similar to the existing CS
    Application. Now i have flexgrid in one of the form where there are
    controls in the cell and the user can enter the information row wise
    and then on close of the form the data is saved. And one more
    requirement to load the grid with a single editable row(some of the
    cells may be list boxes, some may be calendar control) and then save
    the information to the DB. I know that we can use itemtemplate to
    place the controls in the datagrid but needs more clarrification on
    this.

    I wanted to check if all these things are possible using a datagrid

    Thanks in advance

    Harish M.R
     
    Harish, Oct 23, 2003
    #1
    1. Advertising

  2. Hi Harish!

    Create a datagrid with one or more template columns (At least if you wish to
    show dropdown lists and such)
    Edit the template column. In the Item Template you add controls that will
    show the information to the user.
    In the Edit Item Template you add controls that allows the user to change
    the data.

    To allow the user to edit the data you need to set the EditItemIndex of the
    datagrid. When you do this the row corresponding to the index will change
    into editmode.

    You can add a specific Edit, Update, Cancel column to the datagrid. When
    using this type of column the datagrid fires the following events
    (DataGrid dg)
    dg.EditCommand : Is fired when the user presses a button with the
    commandname Edit
    dg.UpdateCommand : Is fired when the user presses a button with the
    commandname Update
    dg.CancelCommand : Is fired when the user presses a button with the
    commandname Cancel

    When the datagrid fires the EditCommand event you need to set the datagrids
    EditItemIndex to the same index
    as the button that was pressed.

    private void dg_EditCommand(object sender, DataGridCommandEventArgs e)
    {
    dg.EditItemIndex = e.Item.ItemIndex;
    UpdateDataGridData();
    }

    When the datagrid has finnished editing (After pressing either Update or
    Cancel the corresponding event is fired)
    In both these you need to tell the datagrid that the EditItemIndex is -1
    (nothing is being edited)

    You need to save the data while being edited. Personally I use home made
    data carrying classes that I add to an ArrayList. But you could just as well
    use a DataTable or a DataSet. Just update the data in the
    dataset/datatable/customdatacarrier and bind it to the datagrid again to
    update the changes made. Then when the user presses ok just take the
    datacarrier and save it to the db.

    Well, I hope this will give you some ideas at least. Good luck

    //Mikael

    "Harish" <> wrote in message
    news:...
    > Dear All,
    >
    > I am being assigned a task of developing a .NET web application from
    > an existing client server(CS) application (VB). It is a requirement
    > that much of the things should look similar to the existing CS
    > Application. Now i have flexgrid in one of the form where there are
    > controls in the cell and the user can enter the information row wise
    > and then on close of the form the data is saved. And one more
    > requirement to load the grid with a single editable row(some of the
    > cells may be list boxes, some may be calendar control) and then save
    > the information to the DB. I know that we can use itemtemplate to
    > place the controls in the datagrid but needs more clarrification on
    > this.
    >
    > I wanted to check if all these things are possible using a datagrid
    >
    > Thanks in advance
    >
    > Harish M.R
     
    Mikael Gustavsson, Oct 24, 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. =?Utf-8?B?V291dGVy?=

    Dynamically Loaded controls loading other controls

    =?Utf-8?B?V291dGVy?=, Feb 27, 2006, in forum: ASP .Net
    Replies:
    3
    Views:
    520
    =?Utf-8?B?V291dGVy?=
    Feb 27, 2006
  2. Bob Rock
    Replies:
    1
    Views:
    690
    Cowboy \(Gregory A. Beamer\)
    Sep 17, 2006
  3. David Segall
    Replies:
    2
    Views:
    465
    Thomas Kellerer
    Jan 2, 2007
  4. Mark

    Loading Different User Controls into a Single DataGrid

    Mark, Dec 8, 2003, in forum: ASP .Net Datagrid Control
    Replies:
    3
    Views:
    169
    lostinet
    Dec 10, 2003
  5. Replies:
    4
    Views:
    345
Loading...

Share This Page