473,320 Members | 1,876 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

How to reference the new row in datagrid from codebehind

Hi

I use the Datagrid webcontrol on my web page, and I use the following client-side javascript to duplicate the current row to the datagrid. But when I loop through the data in datagrid from codebehind, it does not include this new row. Did I miss something? What should I do to reference this new row from codebehind? Thanks

JP Goo

var oTable = document.getElementById("myDataGrid")
var iCurRowIndex = window.event.srcElement.parentElement.parentElemen t.rowIndex
var oCurRow = oTable.rows(iCurRowIndex)
var oNewRow
var oNewCell

oNewRow = oTable.insertRow(iCurRowIndex + 1)
oNewRow.align = "Center"

for (var i = 0; i < oCurRow.cells.length; i++)
oNewCell = oNewRow.insertCell(-1)
oNewCell.innerHTML = oCurRow.cells(i).innerHTML
}
Nov 22 '05 #1
1 1466
"John Good" <an*******@discussions.microsoft.com> wrote in message
news:3A**********************************@microsof t.com...
I use the Datagrid webcontrol on my web page, and I use the following

client-side javascript to duplicate the current row to the datagrid. But
when I loop through the data in datagrid from codebehind, it does not
include this new row. Did I miss something? What should I do to
reference this new row from codebehind? Thanks!

You can't. You see, on the server side you might have a DataGrid
control, but on the client you just have a bunch of assorted HTML tags
that just happen to look like a grid. Think not in terms of what the
things look like, but in terms of what information gets submitted to the
server when the user hits the button.

Remember - to the browser, an ASP.NET page is just a huge form with lots
of HTML in it. You can have a hidden field on this form, and have
client-side JavaScript set a value in this field, indicating that it has
just duplicated row X. On the server side, when you receive this value
in a post-back, you need to duplicate row X in your server-side DataGrid
control.
--
With best wishes,
Igor Tandetnik

"For every complex problem, there is a solution that is simple, neat,
and wrong." H.L. Mencken
Nov 22 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: John Good | last post by:
Hi I use the Datagrid webcontrol on my web page, and I use the following client-side javascript to duplicate the current row to the datagrid. But when I loop through the data in datagrid from...
1
by: Tim | last post by:
I have a RadioButtonList inside the EditItemTemplate of a Datagrid. On the Edit command of the datagrid I am calling the following command: public void dgNodeBranches_Edit(object sender,...
9
by: Max | last post by:
How do I reference a datagrid on a page from a user control on that page? In my user control, I'd like to have something like this... MyDataGrid being on the page, not in the user control... I...
4
by: Kristoffer Arfvidson | last post by:
Im trying to get access to a table in codebehind, because the information in this table is different depending on what it says in the database... So, either I have to access it from codebehind,...
2
by: Ben | last post by:
Hi, I'd like to have a datagrid that has a dropdownlist in the pager control for setting the page size. I can get the control into the pager inside the datagrid itemcreated event by checking for...
2
by: Mark | last post by:
Hi, I'm fairly new to .NET and having problems getting an ASP.NET page working on my web host. The page works fine on my PC running against localhost. I have a MySQL database and a simple C#...
0
by: Tigrou | last post by:
Hello, I'm searching for a solution who permit me to create an TemplateColumn in a DataGrid into codebehind... I found only solution for create it into the ASPX code... My problem is to find...
2
by: Tigrou | last post by:
Hello, I'm searching for a solution who permit me to create an TemplateColumn in a DataGrid into codebehind... I found only solution for create it into the ASPX code... My problem is to find...
4
by: Kurt Schroeder | last post by:
I have a simple aspx page called type with a datagrid/w id=dGrdTyp My code behind page is not reconizing the control on the aspx page. Visualstudio.Net flaggs the dgrdTyp as undefined. Any Help?...
1
by: Brock | last post by:
First note that I am using Framework 1.1. I have an .aspx page that is displaying a list of employees, but only the Employee Number, First Name, Last Name, and Title. It is working great. I...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.