User input directly into datagrid or table?

  • Thread starter Thread starter Stephen
  • Start date Start date
S

Stephen

Hi
I need to set up a table or datagrid where the user is able to input
values directly into the cells. What i am attempting to build is a
page that displays all the days of the year with the columns being
months and the rows being each day in the month, the user will then
input the amount of rainfall that they received on the corresponding
day. How would i go about setting up a table or datagrid to achieve
this?

Thanks
Stephen
 
Stephen said:
Hi
I need to set up a table or datagrid where the user is able to input
values directly into the cells. What i am attempting to build is a
page that displays all the days of the year with the columns being
months and the rows being each day in the month, the user will then
input the amount of rainfall that they received on the corresponding
day. How would i go about setting up a table or datagrid to achieve
this?

That depends. What does your data look like? Do you have a database table
with 12 columns in each row? And do you have 31 rows in your database?
You're only collecting data for a single year?

In that case, just use a standard DataGrid bound to your data. Add an
EditCommandColumn, and on Update, save the changed row to the database. It's
the canonical DataGrid application.

John Saunders

P.S. Or, are you really asking a more specific question?
 
Stephen said:
Hi
I need to set up a table or datagrid where the user is able to input
values directly into the cells. What i am attempting to build is a
page that displays all the days of the year with the columns being
months and the rows being each day in the month, the user will then
input the amount of rainfall that they received on the corresponding
day. How would i go about setting up a table or datagrid to achieve
this?

Thanks
Stephen
 
Hi John, thanks for the reply
Sorry for being ambiguous before. My database table will not be in the
same format as the datagrid that I wish to display to the user. The
database table will contain an ID field, a date field and rainfall
amount field.
All I am really looking for is grid of some kind that the user can
directly add numerical values to. I was playing around with both the
datagrid and html table components and I couldn't find a way to let
the user alter the data that was being displayed on them.
 
Hi John, thanks for the reply
Sorry for being ambiguous before. My database table will not be in the
same format as the datagrid that I wish to display to the user. The
database table will contain an ID field, a date field and rainfall
amount field.
All I am really looking for is grid of some kind that the user can
directly add numerical values to. I was playing around with both the
datagrid and html table components and I couldn't find a way to let
the user alter the data that was being displayed on them.

So, you want to edit the data in the grid, but not the data in the database?
And, do you need the data to be in edit mode all the time, so that the user
can just go edit it without clicking an Edit button? Just like a
spreadsheet?

If so, try using a DataList control, with the ItemTemplate containing a
TextBox control.

John Saunders
 
Hi again John
Yeah that is exactly what I am trying to achieve, I have just had a
look at the datalist and it looks like that would do the trick.
Just one question though, do you know a way to get/set the text of the
textboxes held in the list at run time?
Thanks for all your help
Stephen
 
Hi again John
Yeah that is exactly what I am trying to achieve, I have just had a
look at the datalist and it looks like that would do the trick.
Just one question though, do you know a way to get/set the text of the
textboxes held in the list at run time?

Yes. The DataList has an Items collection inside of which the Textboxes are
instantiated. If your textboxes are called "txtCellData", then you can use

dataList.Items(i).FindControl("txtCellData")

to gain access to the Textbox.

John Saunders
 
Hi John
I have it working now as I had envisaged it working, thanks heaps for
all your help!!
Stephen
 
Back
Top