471,852 Members | 1,336 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

not showing in the html source

greetings people

I am new to Ajax and javascript, yet i have little time to learn it all. Question is:

i am using javascript to create my DOM Table and AJAX that returns a DataSet to my Javascript to fill information in the table. Code looks like this:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>

<script language = javascript>

function DoWork()
var val = "1";



function Result(response)
var tblHead = tbl.createTHead();
var headrow = tbl.insertRow();

var headcell = headrow.insertCell(0);

var selchk = document.createElement("input");
selchk.setAttribute("onclick","javascript:SelectAl lCheckboxes(this);");
headcell.innerHTML = "Select All";

var headcell2 = headrow.insertCell(1);
headcell2.innerHTML = "Company ID";

var headcell3 = headrow.insertCell(2);
headcell3.innerHTML = "Company Name";

var headcell4 = headrow.insertCell(3);
headcell4.innerHTML = "Type Of Company";


// Continue from here

var rows = response.value.Tables[0].Rows.length;

for (var i = 0; i < rows - 1; i++)
var row = tbl.insertRow();

var cell0 = row.insertCell(0);
var chk = document.createElement("input");
chk.setAttribute("id", "chk" + i);

var cell = row.insertCell(1);
var lnk = document.createElement("a");
lnk.setAttribute("href","Companies.aspx?" + response.value.Tables[0].Rows[i].CompanyID);
lnk.innerHTML = response.value.Tables[0].Rows[i].CompanyID;

var cell2 = row.insertCell(2);
cell2.innerHTML = response.value.Tables[0].Rows[i].Name;

var cell3 = row.insertCell(3);
cell3.innerHTML = response.value.Tables[0].Rows[i].TypeOfCompany;


<form id="form1" runat="server">
<input type="button" id="btn" onclick="javascript:DoWork();"/>

<table id="tbl">




When i click the button the table shows perfectly with all the information. The problem is i cannot see the update in the HTML Source i.e. the DOM table is empty. Therefore how can i manipulate certain rows or cells in the table that the user checked. or how can i check all the rows if the user wanted to select all rows. i guess the elements of type checkbox dont exist. An example of the selectallcheckboxes function is like this:

function SelectAllCheckboxes(spanChk){

var theBox = spanChk;
var elm = theBox.form.elements;

for (i=0;i<elm.length;i++)
if (elm[i].type == "checkbox" && elm[i].id != "filterChk" && elm[i].id != "slctAll")
if (elm[i].checked != theBox.checked)


Thanking u guys in advance

kind regards
Dec 25 '06 #1
2 1670
1,892 Expert 1GB
Did you leave out some of the code? I don't see any ajax.
Dec 25 '06 #2
Did you leave out some of the code? I don't see any ajax.


this is the code for the AJAX. Incase you need to know, i am using the Microsoft AJAX library and i am calling the AJAX method from javascript simply by classname.method which will be _Default.GridData(val,Result); which then passes the DataSet to a javascript Result(response) Function. (response in this case is the DataSet that i am using in javascript that i got from the ajax method).

public DataSet GridData(string x)
SqlConnection connection = Connections.GetSqlConnection();

WebService.Service wService = new WebService.Service();

SqlDataAdapter adapter = new SqlDataAdapter("SELECT FieldName, HeaderText FROM Fields WHERE TableID = " + x + " AND IsDisplayed = 1 ORDER BY IsKey DESC", connection);

DataTable Dtbl = new DataTable();


string tblName = Convert.ToString(wService.ExecuteSqlCommand("SELEC T TableName FROM Tables WHERE TableID = " + x, true));

string sqlstr = "SELECT ";

int y = 0;

// Generating Sql Statement
foreach (DataRow dr in Dtbl.Rows)
if (y < Dtbl.Rows.Count - 1)
sqlstr += dr["FieldName"].ToString() + ", ";

else if (y == Dtbl.Rows.Count - 1)

sqlstr += dr["FieldName"].ToString();
sqlstr += " FROM " + tblName;

SqlDataAdapter dAdapter = new SqlDataAdapter(sqlstr, connection);

DataSet ds = new DataSet();


return ds;
Dec 25 '06 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

3 posts views Thread by david | last post: by
1 post views Thread by Merijn Boom | last post: by
1 post views Thread by news8080 | last post: by
5 posts views Thread by gregmercer | last post: by
9 posts views Thread by Alex D. | last post: by
reply views Thread by YellowAndGreen | last post: by
reply views Thread by aboka | last post: by

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.