Saturday, March 31, 2012
Table Rows
I can only add one row to a Table control. Is there a property that
restricts adding multiple rows? I've tried several different ways.
I've gotten to the point where I can add the information I need for
the second row but it only replaces the original info from the first
row, resulting in still only one row.
ThanksHow exactly are you trying to do this, in code, based on populating from
database?
(show us how you're trying to do it)
David Wier
http://aspnet101.com
http://iWritePro.com - One click PDF, convert .doc/.rtf/.txt to HTML with no
bloated markup
"Looch" <lucianoj2005@.yahoo.com> wrote in message
news:22db0303-349e-4e5e-a6f9-003c3cde7333@.62g2000hsn.googlegroups.com...
> All,
> I can only add one row to a Table control. Is there a property that
> restricts adding multiple rows? I've tried several different ways.
> I've gotten to the point where I can add the information I need for
> the second row but it only replaces the original info from the first
> row, resulting in still only one row.
> Thanks
Here's the code I'm using, the 'else' statement below never gets ran
regardlesss how many times the cmdAdd button is clicked.
protected void Page_Load(object sender, EventArgs e)
{
ddlQuantity.Items.Clear();
ddlItem.Items.Clear();
ddlQuantity.Items.Add("1");
ddlQuantity.Items.Add("2");
ddlQuantity.Items.Add("3");
ddlQuantity.Items.Add("4");
ddlItem.Items.Add("Test");
ddlItem.Items.Add("Test2");
Session.Add("RowCount", (int)ItemTable.Rows.Count);
}
protected void cmdAdd_Click(object sender, EventArgs e)
{
if (Convert.ToInt32(Session["RowCount"]) == 0) //For the first
time cmdAdd is clicked
{
row.ID = "row" + ItemTable.Rows.Count.ToString();
cell.Width = 343;
cell.ID = "cell" + ItemTable.Rows.Count.ToString();
cell2.Width = 125;
cell2.ID = "cell2" + ItemTable.Rows.Count.ToString();
cell2.HorizontalAlign = HorizontalAlign.Center;
ItemTable.Rows.Add(row);
row.Cells.Add(cell);
row.Cells.Add(cell2);
ItemTable.Rows[0].Cells[0].Text = ddlItem.Text;
ItemTable.Rows[0].Cells[1].Text = ddlQuantity.Text;
ItemsToOrder items = new ItemsToOrder();
items.ItemName = ddlItem.Text;
items.Quantity = ddlQuantity.Text;
Session.Add("ItemOrder", items);
Session["RowCount"] = ItemTable.Rows.Count;
}
else //For every other time the button is clicked
{
txtPendingShip.Text = "Test";
}
}
Is there any reason you would need to rebuild the items in the dropdownlist
on every postback, and not surround it with an if/then/postback block?
David Wier
http://aspnet101.com
http://iWritePro.com - One click PDF, convert .doc/.rtf/.txt to HTML with no
bloated markup
"Looch" <lucianoj2005@.yahoo.com> wrote in message
news:d55f2313-88be-4980-83ab-b43430b9b674@.62g2000hsn.googlegroups.com...
> Here's the code I'm using, the 'else' statement below never gets ran
> regardlesss how many times the cmdAdd button is clicked.
> protected void Page_Load(object sender, EventArgs e)
> {
> ddlQuantity.Items.Clear();
> ddlItem.Items.Clear();
> ddlQuantity.Items.Add("1");
> ddlQuantity.Items.Add("2");
> ddlQuantity.Items.Add("3");
> ddlQuantity.Items.Add("4");
> ddlItem.Items.Add("Test");
> ddlItem.Items.Add("Test2");
> Session.Add("RowCount", (int)ItemTable.Rows.Count);
> }
> protected void cmdAdd_Click(object sender, EventArgs e)
> {
> if (Convert.ToInt32(Session["RowCount"]) == 0) //For the first
> time cmdAdd is clicked
> {
> row.ID = "row" + ItemTable.Rows.Count.ToString();
> cell.Width = 343;
> cell.ID = "cell" + ItemTable.Rows.Count.ToString();
> cell2.Width = 125;
> cell2.ID = "cell2" + ItemTable.Rows.Count.ToString();
> cell2.HorizontalAlign = HorizontalAlign.Center;
> ItemTable.Rows.Add(row);
> row.Cells.Add(cell);
> row.Cells.Add(cell2);
> ItemTable.Rows[0].Cells[0].Text = ddlItem.Text;
> ItemTable.Rows[0].Cells[1].Text = ddlQuantity.Text;
> ItemsToOrder items = new ItemsToOrder();
> items.ItemName = ddlItem.Text;
> items.Quantity = ddlQuantity.Text;
> Session.Add("ItemOrder", items);
> Session["RowCount"] = ItemTable.Rows.Count;
> }
> else //For every other time the button is clicked
> {
> txtPendingShip.Text = "Test";
> }
> }
I was going to address that once I got past the row adding hurdle,
I've been stuck on that for about a day now...
Looch wrote:
> ItemTable.Rows.Add(row);
Try
ItemTable.Rows.Add(row.Clone);
otherwise you're always adding a /reference/ to the same variable rather
than the data in that variable.
Andrew
Table Rows
I have dynamically created a table in ASP.NET using tbl.rows.add(tr)
method where 'tbl' is a System.Web.UI.WebControls.Table. and tr is a
TableRows object.
Any ideas why I can't then itterate through the table object and reference
each of the rows using:
Dim tb as tablesRow
For Each tr In tbl.Rows
xx = tr.Cells(1).Text
Next
There appears to be no rows in the table ie. tbl.tablerows.count = 0
TIA
TimDim t as new table
Page.Controls.Add(t)
Dim r As TableRow
Dim c As TableCell
For i As Int32 = 0 To 5
r = New TableRow
c = New TableCell
c.Text = i.ToString
r.Cells.Add(c)
t.Rows.Add(r)
Next
For Each r In t.Rows
Response.Write("<BR>Cell Value = " & r.Cells(0).Text)
Next
"Tim" <timbryant@.smoothit.co.uk> wrote in message
news:OUr4bISvFHA.2064@.TK2MSFTNGP09.phx.gbl...
> Hello,
> I have dynamically created a table in ASP.NET using tbl.rows.add(tr)
> method where 'tbl' is a System.Web.UI.WebControls.Table. and tr is a
> TableRows object.
> Any ideas why I can't then itterate through the table object and reference
> each of the rows using:
> Dim tb as tablesRow
> For Each tr In tbl.Rows
> xx = tr.Cells(1).Text
> Next
> There appears to be no rows in the table ie. tbl.tablerows.count = 0
> TIA
> Tim
>
>
Tim,
If you are trying to access the rows on postback, note, that you have to
re-create dynamucally created objects in the code.
Eliyahu
"Tim" <timbryant@.smoothit.co.uk> wrote in message
news:OUr4bISvFHA.2064@.TK2MSFTNGP09.phx.gbl...
> Hello,
> I have dynamically created a table in ASP.NET using tbl.rows.add(tr)
> method where 'tbl' is a System.Web.UI.WebControls.Table. and tr is a
> TableRows object.
> Any ideas why I can't then itterate through the table object and reference
> each of the rows using:
> Dim tb as tablesRow
> For Each tr In tbl.Rows
> xx = tr.Cells(1).Text
> Next
> There appears to be no rows in the table ie. tbl.tablerows.count = 0
> TIA
> Tim
>
>
Wednesday, March 28, 2012
tables & rows & columns
3 columns. The 3rd column spans the 6 rows and contains a grid. If the
data in the grid has more than 6 rows of data, the other rows spread out
vertically, as if there is extra space in there. I don't want that to
happen, I want the 6 rows to be together as if there is no space between
then. I have tried using height, valign, using a set height and using a
percentage height and it doesn't work. How can I make the 6 rows on the
left align all the way to the top?
<table borderColor=red cellSpacing=0 cellPadding=0 width="100%" border=1
runat="server" ID="Table1">
<tr vAlign=top colspan=4><td> </td></tr>
<tr vAlign=top>
<td valign=top style="HEIGHT: 15px" align=left width=100>Col 1</td>
<td vAlign=top height=5>Col 2</td>
<td align=right rowspan=6>Col 3<br>Col 3<br>Col 3<br>Col 3<br>Col 3<br>Col
3<br>Col 3<br>Col 3<br>Col 3<br>Col 3<br>Col 3<br>Col 3<br>Col 3<br>Col
3<br>Col 3<br>Col 3<br>Col 3<br>Col 3<br>Col 3<br>Col 3<br>Col 3<br></td>
<td align=left rowspan=6>Col 4</td></tr>
<tr valign=top height=1>
<td valign=top>col 1</td>
<td valign=top>col 2</td>
</tr>
<tr valign=top height=1>
<td valign=top>col 1</td>
<td valign=top>col 2</td>
</tr>
<tr valign=top height=1>
<td valign=top>col 1</td>
<td valign=top>col 2</td>
</tr>
<tr valign=top height=1>
<td valign=top>col 1</td>
<td valign=top>col 2</td>
</tr>
<tr valign=top>
<td valign=top>col 1</td>
<td valign=top>col 2</td>
</tr>
</table>Maybe I didn't really get your question, but I do not see a grid in the
3rd column.
But did you try to put another table into one cell? That often works.
Remy Blaettler
www.collaboral.com
tables & rows & columns
3 columns. The 3rd column spans the 6 rows and contains a grid. If the
data in the grid has more than 6 rows of data, the other rows spread out
vertically, as if there is extra space in there. I don't want that to
happen, I want the 6 rows to be together as if there is no space between
then. I have tried using height, valign, using a set height and using a
percentage height and it doesn't work. How can I make the 6 rows on the
left align all the way to the top?
<table borderColor=red cellSpacing=0 cellPadding=0 width="100%" border=1
runat="server" ID="Table1">
<tr vAlign=top colspan=4><td> </td></tr
<tr vAlign=top>
<td valign=top style="HEIGHT: 15px" align=left width=100>Col 1</td>
<td vAlign=top height=5>Col 2</td>
<td align=right rowspan=6>Col 3<br>Col 3<br>Col 3<br>Col 3<br>Col 3<br>Col
3<br>Col 3<br>Col 3<br>Col 3<br>Col 3<br>Col 3<br>Col 3<br>Col 3<br>Col
3<br>Col 3<br>Col 3<br>Col 3<br>Col 3<br>Col 3<br>Col 3<br>Col 3<br></td>
<td align=left rowspan=6>Col 4</td></tr>
<tr valign=top height=1>
<td valign=top>col 1</td>
<td valign=top>col 2</td>
</tr>
<tr valign=top height=1>
<td valign=top>col 1</td>
<td valign=top>col 2</td>
</tr>
<tr valign=top height=1>
<td valign=top>col 1</td>
<td valign=top>col 2</td>
</tr>
<tr valign=top height=1>
<td valign=top>col 1</td>
<td valign=top>col 2</td>
</tr>
<tr valign=top>
<td valign=top>col 1</td>
<td valign=top>col 2</td>
</tr
</tableMaybe I didn't really get your question, but I do not see a grid in the
3rd column.
But did you try to put another table into one cell? That often works.
Remy Blaettler
www.collaboral.com
Monday, March 26, 2012
Tables, Rows and Columns....Questions....
I have inserted a table and had adjusted the table to what look nice to me. I've added rows, columns and all the extra goodies. The problem is that, whenever I launched it in the web browser, the table expands all the way to the upper right and left of the screen. Is there a way to make the table so that it's fixed, meaning that it stays the same way as what I have in the working screen.
I'm using Visual Studio 2005...at the moment.
Any suggestion...thanks,
NoobKid
You probably have the width set to 100% for the table - remove the width percentage and give it an exact pixel amount - that way it will stay the same size each time it's viewedTuesday, March 13, 2012
td tag generating faulty code
a single column menu controls with 5 rows. each row is supposed to have a
image in link tag. The problem is that ASP.Net framework generates closing
"td" tags on new line. This causes to show extra white pixels at the bottom
of each image. This is because of a known bug in "IE" where it has issues
with closing "td" tag on new line.
Question .... is there a way to control the HTML tags generated by ASP.Net
controls so that I can get the UI the way I want it?
Thanks
Naveen K Kohli
http://www.netomatix.comYou would have to override the Render method of the server control, or
possible create a custom control where you specify the HTML to rendered.
David Lloyd
MCSD .NET
http://LemingtonConsulting.com
This response is supplied "as is" without any representations or warranties.
"Naveen K Kohli" <naveenkohli@.hotmail.com> wrote in message
news:#xNFQq#VFHA.1384@.TK2MSFTNGP09.phx.gbl...
I have created a user control using asp:table control. The control generates
a single column menu controls with 5 rows. each row is supposed to have a
image in link tag. The problem is that ASP.Net framework generates closing
"td" tags on new line. This causes to show extra white pixels at the bottom
of each image. This is because of a known bug in "IE" where it has issues
with closing "td" tag on new line.
Question .... is there a way to control the HTML tags generated by ASP.Net
controls so that I can get the UI the way I want it?
Thanks
Naveen K Kohli
http://www.netomatix.com