Adding Dynamic row to Row

I have written the following code in javascript. This code is working fine in FireFox but not in IE 7.

Need help so that it should  also work fine in IE7.

Thanks. 

var repeater= document.getElementById('<%=repeater.ClientID %>');

        var obj = result;

        var newRow = document.createElement("tr");

        var newCell = document.createElement("td");
        var ctrlInputHid = document.createElement("input");
        ctrlInputHid.type = "hidden";
        ctrlInputHid.setAttribute("value", obj.ID);
        newCell.appendChild(ctrlInputHid);
        newCell.appendChild(document.createTextNode(obj.Name));
        newRow.appendChild(newCell);


        newCell = document.createElement("td");
        newCell.appendChild(document.createTextNode(obj.MaritalStatus));
        newRow.appendChild(newCell);


        newCell = document.createElement("td");
        ctrlInputEdit = document.createElement("input");
        ctrlInputEdit.type = "button";
        ctrlInputEdit.setAttribute("value", "Edit");
        ctrlInputEdit.setAttribute("onclick", "Select(" + obj.ID + "); return false;");
        newCell.appendChild(ctrlInputEdit);
        newRow.appendChild(newCell);

      

        repeater.appendChild(newRow);

0
Haris
1/27/2009 1:16:46 PM
asp.net.getting-started 91979 articles. 4 followers. Follow

16 Replies
628 Views

Similar Articles

[PageSpeed] 46

What is the error? 

Jef Claes
~~~~~~~~~~

Visit my blog
0
Nemesis116
1/27/2009 1:29:22 PM

 There is no error message in IE but it didnt add the row as it did in FireFox

0
Haris
1/27/2009 1:33:32 PM

Is the row there in the HTML?

Chances are it's there, but IE7 isn't rendering it properly because it doesn't have any content.

0
Mr
1/27/2009 1:40:04 PM
Yep, take a look at the source of the page.

Jef Claes
~~~~~~~~~~

Visit my blog
0
Nemesis116
1/27/2009 1:49:13 PM

 No the row is not in the source.

0
Haris
1/27/2009 2:02:42 PM

Ah, it wouldn't be in the page source as it's been added dynamically.

You'll have to use something like Firebug's html inspector to view the code AFTER your javascript has been fired off.

0
Mr
1/27/2009 2:12:08 PM

Have you tried debugging the javascript by stepping through the code in Visual Studio?

 


Jef Claes
~~~~~~~~~~

Visit my blog
0
Nemesis116
1/27/2009 2:12:14 PM

 But why IE is not rendering the row ?

0
Haris
1/27/2009 2:55:23 PM

Haris Alim:

 But why IE is not rendering the row ?

 

It's hard to tell why if you can't/won't show us the source code after the javascript has been run.

Get Firebug (https://addons.mozilla.org/en-US/firefox/addon/1843)

Go to your page in Firefox, with it rendering properly, grab the source for the rendered row and we'll tell you why IE doesn't like it.

0
Mr
1/27/2009 3:12:09 PM

This is the rendered code in firefox.

<tr>
  <td><input value="29173507" type="hidden">1 2 3</td>
  <td>Married</td>
   <td><input onclick="Select(29173507); return false;" value="Edit" type="button"></td>
</tr>
0
Haris
1/27/2009 3:21:24 PM
Looks like there's a script error in IE somewhere, do you have script debugging disabled in IE?
0
Mr
1/27/2009 3:33:40 PM

 No script debugger is enabled. But there is no script error.

0
Haris
1/27/2009 3:38:03 PM

Could you post the full code, not just a snippet and I can try and re-create the problem.

0
Mr
1/27/2009 3:42:52 PM

goto http://forums.asp.net/130.aspx for expert help on javascript

0
ixtli
2/2/2009 3:47:18 AM

Try this code to create rows , since IE and FireFox have different api's for adding dynamic rows :-

 

var myAgent = navigator.userAgent.toLowerCase();
var myVersion = parseInt(navigator.appVersion);

var isIE = ((myAgent.indexOf("msie") != -1)
         && (myAgent.indexOf("opera") == -1));
var isFF = ((myAgent.indexOf('mozilla') != -1)
           && (myAgent.indexOf('spoofer') == -1)
           && (myAgent.indexOf('compatible') == -1)
           && (myAgent.indexOf('opera') == -1)
           && (myAgent.indexOf('webtv') == -1)
           && (myAgent.indexOf('hotjava') == -1));


function createRow(grid, rowId, align)
{
    var newRow;
    if (isIE)
    {
        newRow = grid.insertRow();
    }
    else
    {
        newRow = document.createElement("tr");
        newRow.style.display = 'none';
        grid.tBodies[0].appendChild(newRow);
    }

    newRow.setAttribute("id", rowId);
    newRow.setAttribute("align", align);

    return newRow;
}

function createCell(row, cursor)
{
    var newCell;
    if (isIE)
    {
        newCell = row.insertCell();
        if (cursor != '')
            newCell.style.cursor = cursor;
    }
    else
    {
        newCell = document.createElement("td");
        row.appendChild(newCell);
        if (cursor != '')
            newCell.setAttribute("style", "cursor: " + cursor + ";");
    }
    return newCell;
}

  

 

Use this code to create Row and Cell, and use rest of your code for adding hidden fields and textboxes etc


Zeeshan Umar

~ Please Mark as Answer if it solves your query ~
0
sirdneo
2/2/2009 7:19:58 AM

 Thanks Zeeshan.It solves my problem.

0
Haris
2/2/2009 8:39:10 AM
Reply:

Similar Artilces:

adding a blank header row /row above the header row
is it possible to add a blank row above the header row in gridview for adding some links and buttons the links will respond to thae data in the grid and the buttons are for login / regisration etc....  if yes how it can be done or how do i achieve it. Its better that u create a table with a single row with columns matching the GridView columns. Set the table width same as the GridView width. This will make the GridView Look as if there is a row above its header.Please do not forget to click Mark As Answer on the post that helped you. Regards,Iam Srikanth Reddy....

MyTable.Rows.Count does not increase when dynamically adding rows
I have a table having two rows initially. And i have also two buttons that adds and delete rows dynamically.. When i click the "add row" button it will add rows sucessfully. My first problem is, i notice that the value of table1.rows.count does not increasing. It always remain on 2. Which i initially set on design time. Also after solving this problem, please help me to do the things to delete the last row when i click the "delete row" . Thanks please post some codeMy Regards to All,Jason -- O-H-I-O Go Buckeyes! #1--- LIVESTRONG.ORG --- Please support the battle against cancer! ...

Problem accessing Ids of last row after dynamically adding row to GridView
I'm adding a "header" row to a gridview.  In the RowDataBound method I get the table of the gridview (e.Row.Parent), I then create a new row:Dim newRow As New GridViewRow(0, 0, DataControlRowType.DataRow, DataControlRowState.Normal)Add some html to it and then add the row to the table:ParentTable.Rows.Add(newRow)This renders correctly.  However, in the gridview rows, I also have a link button.  For the most part this works, I click on the link button and am able to get the Id from the command argument.Funny thing is that if I click the link button in the las...

Returning n rows, setting start row, total number of rows
Hi, I'm try to find out how ado.net can perform some of the things i am able to do in ado. Here is the scenario: I will be searching a table that may have 1000's of rows. I want to be able to dictate how many rows (page size) to return and what the starting row number is and be able to find out how many total rows would be returned by the query. Using old ado recordsets I was able to get the recordset and get the count or all the rows (.recordcount - ormaybe it was .rowcount) and then jump to the starting position (.absoluteposition). How can I do the equivalent in .net? From loo...

Adding a new row between rows
Hi to all. I'm trying to do a sort of SubReport. At this moment I have This Code made. It verifies if the column is equal it will erase it's text. What I would like to do now is if the Cell is not Equal then it will create a row with a label that says Sub Report. I tried some code but it inserts the row at the end. Can any one help me? protected void gridDefectReport_RowDataBound(object sender, GridViewRowEventArgs e)    {         if (e.Row.RowIndex > 0)        {     &nb...

get the row element values using row index for dynamic dropdownlist using javascript
Friends,How to get the row element values using row index for dynamic dropdownlist using javascript ?Thanks in advance  I want creating dynamic dropdownlist  using javascript. I am working on deleting a row. function DeleteRow(r) { var i = r.parentNode.parentNode.rowIndex;document.getElementById("ctl_Contentmain_tbldynamic").deleteRow(i);var str = document.getElementByName("ddljobs");   alert(str); } Check out this. var str = document.getElementById('<%=ddljobs.ClientID%>');   Thanks,santosh_maharajaPlease mark as answer ...

How to set the row number and get the row number for ("selected row) in Datagrid
I face a problem that i can't get the selected row of the datagrid in both server side script (VB.net) and client side script (javascript) As i can't use the button column / hyperlink column in the datagrid. Thus , i need to handle the change the background color of the selected row and also to get the selected row number for Update/Delete. Thanks in advance. This depends on how do you perform the selection. Do you want to implement chaning of the SelectedRow at the client side without any postback? If you have no issues with postback, then you can do s little trick here: 1. ...

First Row, Next Row, Prior Row, Last Row
I have a SQL Anywhere 7.0 Database, have a table Product_detail which contains Column Name Datatype width Null Default batch_id char(10) No None prod_id Integer No None employee_id Integer No None quantity Integer No None price Numeric (14, 2) No None Its primary key is batch_id I have a Freeform Datawindow with this table I want to provide the first row, next row, prior row and last row Ho...

Dynamically adding a new row & assigning total values of the existing row columns in a grid view
Hi All, My web application has a aspx(C#) file which shows the report data in a  grid view.  the grid has first two coulmns fixed and columns 3 & onwards are dynamically generated. What I want - A new row at the end of grid should be added dynamically which should display the total of each column 3 onwards. Any help would be much appreciated.  Thanks, Srain.     http://aspalliance.com/782 If you need three dynamic columns total to be displayed then declare three Global valibales and In RowDataBound event try like this  If (e.Row.RowTy...

adding / deleting table rows, and accessing controls within added rows
Hi everyone,I would like to know what is a good and simple way to achieve this using asp.net.  Basically i would like the ability to add and delete rows, preferably table rows.  Against each row is its delete button, hitting it will delete the corresponding row.  There is only 1 Add button to add a new row.  In each row, there are say 2 textboxes.  When i hit, say a calculate button, i wish to be able to access all the available textboxes in all the available rows in the event handler, and say just output a sum.If GridView is suggested, could you please explain why i...

How to get data from database row by row
I try to get data from a database row by row, I am using DataReader, the return result is not I expected, don't know how to solve it. Here is my sample code: --------------------------------------------Dim commandText As String = "select * from customer "Dim con As New OleDbConnection("Data Source=c:\company.mdb;Persist Security Info=False; Provider=Microsoft.Jet.OLEDB.4.0;")Dim Cmd As New OleDbCommand(commandText, con)Dim reader As OleDbDataReader = Cmd.ExecuteReader()             Using con       &nbs...

Get row index of found row
How do I find the row index after searching a Dataset Table? For example, <code> Dim recId As String = Request.QueryString("r") Dim r As DataRow Dim tbl As DataTable = ds.Tables("drivers") tbl.PrimaryKey = New DataColumn() {tbl.Columns("recId")} If NOT IsNothing(tbl.Rows.Find(recId)) Then                r = tbl.Rows.Find(recId) End If </code> Next, I want to know the row index of the row, r, so the user can move foward and back, from this point, through the rows in the table, in order to display...

Get the Row Number or Row ID
Hi, I am using Sybase Central v4.3 with Interactive SQL to query the SQL Commands. My concern is how to get the rownumber or row id in select queries. Is there any in built commands in the ASE. If not please suggest me how to get the rownumber. Thanks.... Unless i'm mistaken, ASE does not use a rowid... it can have a timestamp, but it is updated with every modification to the row. http://infocenter.sybase.com/help/topic/com.sybase.help.ase_15.0.blocks/html/blocks/blocks34.htm -- Cory Sane [TeamSybase] Certified Sybase Associate DBA for ASE 15.0 "Santhanam P" wrote...

Dynamic adding of rows
I  am having a bit of difficulty determining the best approach.  Here is my situation - I have a page that contains some textbox controls that allow the user to enter data.  When the user presses a button, the data in the textboxes needs to be added dynamically to a table.  The table is displayed at the bottom of the page.  In this scenario, the number of rows for the table will be dynamic, since the user can enter as much data as desired.Here is what I have tried thus far:ASP:Table - I was able to add the rows dynamically but the data was not persistent on postback....

Web resources about - Adding Dynamic row to Row - asp.net.getting-started

Dynamics - Wikipedia, the free encyclopedia
Brownian dynamics , the occurrence of Langevin dynamics in the motion of particles in solution (e.g. a grain in water, as was first seen by Brown); ...

Datacenter Dynamics
Datacenterdynamics for data center information, conferences, news, videos, whitepapers and reports globally

Dynamic Chiropractic - chiropractic, news, articles, research & information for chiropractors - Find ...
Dynamic Chiropractic - chiropractic, news, articles, research & information for chiropractors - Find a Chiropractor

The colorful, dark, dynamic art of life: 2015 BioArt winners
In an embryonic mouse torso, researches closely track how the parallel paths of blood vessels (gray) and nerve cells (red) develop. Understanding ...

General Dynamics Corporation Delivers The Future of American Shipping
American Petroleum Tankers receives delivery of first ECO class tanker from General Dynamics\' NASSCO.

Yolanda Foster explains her divorce: ‘chronic illness changed our dynamic’
... is extremely challenging, not only for the person that’s sick, but also for the caregiver,” Foster admitted. “It for sure changed the dynamic ...

Microsoft Dynamics AX delivers the power of the cloud to businesses
Microsoft has announced that the next release of its flagship ERP solution, Microsoft Dynamics AX, will be generally available in the first quarter ...

Yolanda Foster Says Lyme Disease 'Changed the Dynamic' of Her Marriage to David Foster
Yolanda Foster Says Lyme Disease 'Changed the Dynamic' of Her Marriage to David Foster

Microsoft Launches Dynamics CRM 2016
As CRM software's value grows in the enterprise, Microsoft releases an analytics-enabled, more mobile-friendly version of Dynamics CRM.

Three Ways To Create a Dynamic And Engaging Office Environment
VideoPhoto Credit: Stan Phelps How you design your office matters. It sets the stage for how your employees work and interact. The physical environment ...

Resources last updated: 12/9/2015 9:07:52 PM