Forum Moderators: mack

Message Too Old, No Replies

About ASP.NET

Dynamic textbox creation in dynamic table

         

pushpa_n

7:08 am on May 2, 2008 (gmt 0)

10+ Year Member



Hello everyone...
I am new to ASP.NET. So plz help me out to solve my problem...

I want to create a table dynamically which consists of textbox in every cell... I do have a code in Javascript for creating dynamic table, but i am not able insert textbox in every table cell...

My problem actually is that i m working on Creating Time Reporting Tool as my internship project. So i want create a time sheet which allows entry n also retreival of data for fortnights as per calendar selection....
If u people hav ur own ideas abt dis, plz do share with me...

docluv

2:35 pm on May 5, 2008 (gmt 0)

10+ Year Member



The simplest way to do this is using an UpdatePanel and a server-side method to add a record to your table. I think the issue you may be having is you are trying to dynamically add a textbox to the page and the ViewState will not match up. You could also not use the TextBox web control and just use an old fashion Input field, which most likely is how your existing JS works.

pushpa_n

6:32 am on May 6, 2008 (gmt 0)

10+ Year Member



Thankfull for ur reply...
Below i have pasted my javascript function(Got in the net, i didnt get any in ASP.NET) which creates table dynamically. It prints j value as text inside every table cell.
But instead of that i need textboxes in which i can display selected data from database.
Since i am working on Time Tracker which is for fortnight, month's first half consists of 15 days and second half either 15 or 16 days. If its Feb then second half columns completely cahnges. If u have ur own idea of buliding Timesheet plz do share with me...
My timesheet(of fortnight) must be as follows[, separates one column from other]
Client/Description of project, 1[Sun], 2[Mon],......15[Mon], Total

function CreateTable(rowCount, colCount, srcHolder)
{
if(IsValidNumber(rowCount) && IsValidNumber(colCount) && (srcHolder != null) && (srcHolder.canHaveChildren))
{
srcHolder.innerHTML = "";
var srcTable = document.createElement("table");
srcTable.border = 1;
srcTable.borderColor = "Black";
srcTable.height = DEFAULT_HEIGHT;
srcTable.width = DEFAULT_WIDTH;
var tmpRow = null;
var tmpCell = null;
srcHolder.appendChild(srcTable);
for(i=0; i<rowCount; i++)
{
tmpRow = AppendRow(srcTable)
for(j=0; j<colCount; j++)
{
tmpCell = AppendCell(tmpRow);
tmpCell.innerText = j;//This is where i am planning to change tmpCell = null;
}
tmpRow = null;
}
}
}