client side add to a table

J

John Smith

ASP.NET SQL C#
I would like to get data from sql server and display it in a web page table
and be able to edit add delete rows without having to do server pulls.
When the user is finished the user pushes commit button and the data is
transferred back to the sql server.
I would appreciate being pointed at an example of how to do this.
thank you
mark
 
G

Guest

Well Datagrid has the Edit,Delete,Add capabilities..
Look for examples on the Net to get started!
 
A

Anonieko Ramos

Are you referring to disconnected model
where Datasets are stored locally via
write xml and later updates the database
in 1 shot?
 
J

John Smith

yes,

I do not want to do server trips for edit update add rows to the dataset.

mark
 
J

John Smith

Datagrid is a server component from what I read. If you know how to do these
things on the client with no server trips I would appreciate being shown
how.

Mark
 
K

Ken Dopierala Jr.

Hi Mark,

This is how I do it, it is a little complicated but once you get used it
you'll have no problems:

var tblMyTable = document.getElementById('tblNames');
var Rows = tblMyTable.getElementsByTagName('tr');
var NewRow;
var NewCell;

NewRow = tblMyTable.insertRow(Rows.length);
NewCell = NewRow.insertCell(0);
NewCell.innerHTML = "John";
NewCell = NewRow.insertCell(1);
NewCell.innerHTML = "Smith";

Now you have a table with 1 row and 2 columns. I recommend putting:
debugger; after the NewCell = NewRow.insertCell(0) line. Then looking at
NewCell in the watch pane. There you will see the huge number of properties
(i.e. NewCell.bgColor, NewCell.width, and etc.) that you can manipulate.
You can do the same for NewRow and tblMyTable and you'll get a feel for
everything you can do. Good luck! Ken.
 
P

Patrice

Then you'll have to do that client side using JavaScript and handling the
whole "table" model. Weight carefully first if it's worth...

Patrice



--
 
K

Ken Dopierala Jr.

Hi Mark,

If you are putting input controls (i.e. <input type='text' ....>) in your
table, then create a global variable in the <head> section of your page. I
use Counter. Every time I add a row I use the same ID for the controls but
append an incremented Counter (txtName1, txtName2). Then when you submit
your form assign Counter to a hidden input field that you have set to
runat="server":

<input id="hidNumberOfLines" type="hidden" name="hidNumberOfLines"
runat="server">

In your server side code check the value of this hidden control. If it is
greater than 0 then loop and get all your values:

intNumberOfLineItems = CInt(hidNumberOfLines.Value)

For intCounter = 1 To intNumberOfLineItems
strFirstName = CStr(Request("txtFirstName" + CStr(intCounter)))
strLastName = CStr(Request("txtLastName" + CStr(intCounter)))
strAge = CInt(Request("txtAge" + CStr(intCounter)))
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,077
Latest member
SangMoor21

Latest Threads

Top