How to have Whole DataGrid in Editmode 
Author Message
 How to have Whole DataGrid in Editmode

I found a solution for editable columns!!!

I have controls in my app with editable columns that I designed this
weekend.

It's not the cleanest code but it works.

Here's the code that the page.onsubmit implements that gets the values of a
column of Textboxes .

I have a table loaded into a grid, and the ItemTemplate of one of the
columns is a text box.  When the page is submitted I go through the grids
items, which is equal to the number of rows in the table it's representing
and do a findcontrol on the textbox's name "ParentId" in this case and then
get the unique name from it's naming container which allows me to get it's
value from the request parameters returned from the page..

private void Submit1_ServerClick(object sender, System.EventArgs e)

            {

                  //  I saved the dataset that was loaded into the grid in a
session variable.

                  DataSet ds = (DataSet)Session["handofflist"];

                  int nRecords = ds.Tables[0].Rows.Count;

                  int cd = DataGrid1.Items.Count;

                  for (int c = 0; c < DataGrid1.Items.Count;   c++)

                  {

                        Control ParentIdTextBox =
DataGrid1.Items[c].FindControl("ParentId");

                        if (ParentIdTextBox != null)

                        {

                              string viewStateData =
Request.Params.Get(ParentIdTextBox.NamingContainer.UniqueID + ":ParentId");

//((DataColumn)ds.Tables[0].Rows[c]["NEW_PARENT_CONTAINER_ID"]).ReadOnly =
false;

ds.Tables[0].Rows[c]["NEW_PARENT_CONTAINER_ID"] = viewStateData;

                              DataRow r = ds.Tables[0].Rows[c];

                              DataRow r2 = ds.Tables[0].Rows[c];

                        }

                  }

                  DataColumn[] keys = new DataColumn[2];

                  keys[0] = ds.Tables[0].Columns["container_id"];

                  keys[1] = ds.Tables[0].Columns["transfer_id"];

                  ds.Tables[0].PrimaryKey = keys;

                  int count = UpdateAdapter.Update(ds.Tables[0]);

                  DataGrid1.DataSource = ds;

                  DataGrid1.DataBind();

            }



Quote:
> We are assuming that you are referring to a WebForm application.  There is
> not an easy solution to your problem.  You will probably need to create
your
> own grid control that supports this feature.

> Mike and Yannick
> VB .Net Team

> --
> This posting is provided "AS IS" with no warranties, and confers no
rights.


> > I import data in a Datagrid from an Excel spreadsheet...... Done

> > I now need to give an option to edit a column / delete a row. I don't
want
> > to have edit/delete buttons for each row. I want to have all the cells
of
> a
> > selected column in editmode.

> > Update revised data to database

> > Any ideas would be appreciated.

> > Thanks,
> > Raj



Sat, 29 Jan 2005 00:10:42 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Open a doc, grab a range without having the whole doc being tabled

2. EditMode in DataGrid

3. Validating in a datagrid in EditMode

4. Highlight the whole row in DataGrid

5. hightlight a whole row in ADO DataGrid

6. vb6 datagrid rowselector - select a whole row

7. How to highlight the whole row in DataGrid?

8. Having different recordsource in Datagrid : Is it Posibble?

9. Having different recordsource in Datagrid : Is it Posibble?

10. Having different recordsource in Datagrid : Is it Posibble?

11. Need some help with DataGrids (DataGrid-->DataGrid, DataGrid-->Dataset, DataGrid-->XML)

12. ADO movecomplete, delete and EditMode ?

 

 
Powered by phpBB® Forum Software