3 Replies - 3376 Views - Last Post: 04 April 2011 - 07:32 AM Rate Topic: -----

#1 zwickz711  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 8
  • Joined: 14-October 10

Dynamically populating table and saving user input

Posted 04 April 2011 - 06:02 AM

I have an asp.net web application page with a table on it that will populate the rows and cells dynamically with data retrieved from a sql database. Within some of the cells are textboxes with values retrieved from the database. I want to allow the user to be able to change the data to whatever they desire, hit a save button and then save all the changes in the database. Only problem is that when I create the table dynamically you can't retrieve the table data on post back to save the data. I know I can pass the initial table data into a session variable for further use but as far as getting the user changed data I'm at a loss as how to get. I'm wondering if anyone knows of a solution to this problem or if there is a better way to accomplish what I'm trying to do? Thanks for any help in advance.

Is This A Good Question/Topic? 0
  • +

Replies To: Dynamically populating table and saving user input

#2 eclipsed4utoo  Icon User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1524
  • View blog
  • Posts: 5,960
  • Joined: 21-March 08

Re: Dynamically populating table and saving user input

Posted 04 April 2011 - 06:42 AM

Truthfully, I would use a DataGrid or Repeater to do this. I would NOT be using a simple table where you manually create the table rows.

You can change the ItemTemplate of the DataGrid and Repeater to make it look how you want it. This will save you from doing the dynamic stuff and will allow you to get the data from the DataGrid or Repeater on a postback.
Was This Post Helpful? 1
  • +
  • -

#3 zwickz711  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 8
  • Joined: 14-October 10

Re: Dynamically populating table and saving user input

Posted 04 April 2011 - 07:14 AM

I've thought about using a DataGrid but my issue is that I'm pulling data from multiple tables. Plus, the columns would change from time to time based on the active data within the sql tables. Also, not everything in the table is going to be editable. That's why I felt a table would be best. I've never worked with a Repeater before, but I'll look into that.
Was This Post Helpful? 0
  • +
  • -

#4 eclipsed4utoo  Icon User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1524
  • View blog
  • Posts: 5,960
  • Joined: 21-March 08

Re: Dynamically populating table and saving user input

Posted 04 April 2011 - 07:32 AM

The Repeater is very flexible.

It is possible that you can take the HTML that you are building dynamically and put it as the ItemTemplate of the Repeater. Then do some binding using the data from the database, and you will have something way more flexible and easier to use that what you are doing now.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1