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
Wednesday, March 28, 2012
TableCell: BackColor Property But No BackGround Property?
has a background attribute and a bgcolor attribute. The TableCell has a
BackColor property, which is the equivelant of the HTML bgcolor attribute,
but what can I use as an equivelant for the HTML background attribute?
Thanks.
--
Nathan Sokalski
njsokalski@dotnet.itags.org.hotmail.com
http://www.nathansokalski.com/I would have to look but my first thought is this. The control will render
whatever attribute you add. So you can add it declaratively with
attribute="value" syntax or on in the code you can add it through the
Attributes collection on the control.
C#
control.Attributes.Add("Name", "Value");
I think you can do this too, because I think it is a NameValueCollection
which means it handles the add automatically.
control.Attributes["Name"] = "Value";
"Nathan Sokalski" wrote:
> I am using an ASP:Table Control to make a table. I know that the HTML TD tag
> has a background attribute and a bgcolor attribute. The TableCell has a
> BackColor property, which is the equivelant of the HTML bgcolor attribute,
> but what can I use as an equivelant for the HTML background attribute?
> Thanks.
> --
> Nathan Sokalski
> njsokalski@.hotmail.com
> http://www.nathansokalski.com/
>
TableCell.Text property overwrites dynamic control
property, the hidden control is not output. If I set the text first, then
the hidden control is output but the text is not. No errors are generated.
I can make it work by adding a literal control instead of using the text
property, but why doesn't the "simple" method work?
Dim tCell As TableCell = New TableCell
Dim thidden As HtmlInputHidden = New HtmlInputHidden
thidden.ID = "h1"
thidden.Value = "hidden text"
tCell.Controls.Add(thidden)
tCell.Text = "visible text"
tRow.Cells.Add(tCell)Maybe add the text as a literal?
Joe
"Bob Voss" <bvoss@.Xspam.tsts.com> wrote in message
news:%23iH0xNNxDHA.2408@.tk2msftngp13.phx.gbl...
> If I add a hidden input control to a tablecell and then set the cell's
text
> property, the hidden control is not output. If I set the text first, then
> the hidden control is output but the text is not. No errors are
generated.
> I can make it work by adding a literal control instead of using the text
> property, but why doesn't the "simple" method work?
> Dim tCell As TableCell = New TableCell
> Dim thidden As HtmlInputHidden = New HtmlInputHidden
> thidden.ID = "h1"
> thidden.Value = "hidden text"
> tCell.Controls.Add(thidden)
> tCell.Text = "visible text"
> tRow.Cells.Add(tCell)
Monday, March 26, 2012
Tables Asp.Net Visible property
im having serious trouble with my tables in asp.net. i inherited a
system that allowed me to set my tables visble property to true and
false. When i try and create a table using html i do not have that
property.
does anyone know of a different way to create a table '
the system i inherited with the visible property in the tables uses
the following in the top part of the code -
system.web.ui.htmlcontrols.htmltable
is this the reason for the extra property '
my tables dont seem to have this in the code.
thanks
CGHy,
put an asp:panel around your table and you can set the visible property.
<asp:panel id="pan" runat="server">
<table>
<tr>
<td></td>
</tr>
</table>
</asp:panel>
Greez
The Filzmeister
Colin Graham schrieb:
> Hi guys,
> im having serious trouble with my tables in asp.net. i inherited a
> system that allowed me to set my tables visble property to true and
> false. When i try and create a table using html i do not have that
> property.
> does anyone know of a different way to create a table '
> the system i inherited with the visible property in the tables uses
> the following in the top part of the code -
> system.web.ui.htmlcontrols.htmltable
> is this the reason for the extra property '
> my tables dont seem to have this in the code.
> thanks
> CG
You can operate with css rules display and visibility.
Eliyahu
"Colin Graham" <csgraham74@.hotmail.com> wrote in message
news:ee261922.0504210322.483c2912@.posting.google.com...
> Hi guys,
> im having serious trouble with my tables in asp.net. i inherited a
> system that allowed me to set my tables visble property to true and
> false. When i try and create a table using html i do not have that
> property.
> does anyone know of a different way to create a table '
> the system i inherited with the visible property in the tables uses
> the following in the top part of the code -
> system.web.ui.htmlcontrols.htmltable
> is this the reason for the extra property '
> my tables dont seem to have this in the code.
> thanks
> CG
Christian Filzwieser wrote:
> Hy,
> put an asp:panel around your table and you can set the visible
property.
> <asp:panel id="pan" runat="server">
> <table>
> <tr>
> <td></td>
> </tr>
> </table>
> </asp:panel>
>
<asp:PlaceHolder> may be a better choice because it doesn't generate
any contents itself.
Tables Asp.Net Visible property
im having serious trouble with my tables in asp.net. i inherited a
system that allowed me to set my tables visble property to true and
false. When i try and create a table using html i do not have that
property.
does anyone know of a different way to create a table ??
the system i inherited with the visible property in the tables uses
the following in the top part of the code -
system.web.ui.htmlcontrols.htmltable
is this the reason for the extra property ??
my tables dont seem to have this in the code.
thanks
CGHy,
put an asp:panel around your table and you can set the visible property.
<asp:panel id="pan" runat="server">
<table>
<tr>
<td></td>
</tr>
</table>
</asp:panel
Greez
The Filzmeister
Colin Graham schrieb:
> Hi guys,
> im having serious trouble with my tables in asp.net. i inherited a
> system that allowed me to set my tables visble property to true and
> false. When i try and create a table using html i do not have that
> property.
> does anyone know of a different way to create a table ??
> the system i inherited with the visible property in the tables uses
> the following in the top part of the code -
> system.web.ui.htmlcontrols.htmltable
> is this the reason for the extra property ??
> my tables dont seem to have this in the code.
> thanks
> CG
You can operate with css rules display and visibility.
Eliyahu
"Colin Graham" <csgraham74@.hotmail.com> wrote in message
news:ee261922.0504210322.483c2912@.posting.google.c om...
> Hi guys,
> im having serious trouble with my tables in asp.net. i inherited a
> system that allowed me to set my tables visble property to true and
> false. When i try and create a table using html i do not have that
> property.
> does anyone know of a different way to create a table ??
> the system i inherited with the visible property in the tables uses
> the following in the top part of the code -
> system.web.ui.htmlcontrols.htmltable
> is this the reason for the extra property ??
> my tables dont seem to have this in the code.
> thanks
> CG
Christian Filzwieser wrote:
> Hy,
> put an asp:panel around your table and you can set the visible
property.
> <asp:panel id="pan" runat="server">
> <table>
> <tr>
> <td></td>
> </tr>
> </table>
> </asp:panel
<asp:PlaceHolder> may be a better choice because it doesn't generate
any contents itself.