Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Loading controls in Datagrid

Reply
Thread Tools

Loading controls in Datagrid

 
 
Harish
Guest
Posts: n/a
 
      10-23-2003
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
 
Reply With Quote
 
 
 
 
Mikael Gustavsson
Guest
Posts: n/a
 
      10-24-2003
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: om...
> 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



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Issues in ASP.NET 2.0 when dynamically loading user controls or asp.net web controls??? Bob Rock ASP .Net 1 09-17-2006 01:49 PM
Dynamically Loaded controls loading other controls =?Utf-8?B?V291dGVy?= ASP .Net 3 02-27-2006 07:25 PM
Please Wait. Loading...."How to display this on DataGrid while it is getting populated, still not removing all other controls from the web page?" NH ASP .Net 1 08-27-2004 03:43 PM
Please Wait. Loading...."How to display this on DataGrid while it is getting populated, still not removing all other controls from the web page?" NH ASP .Net Datagrid Control 1 08-27-2004 03:37 PM
Loading Different User Controls into a Single DataGrid Mark ASP .Net Datagrid Control 3 12-10-2003 01:40 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57