Saturday, March 31, 2012

Table Rows

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.
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

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
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
>
>

Table Scrolling Problem

Hi,
I have a table which I need to display within a div of a fixed width. The
length of the table exceeds the width of the div which is ok as I can make
the div scrollable. The problem that I have is that the cells in the table
must be a fixed with because they need to co-incide with another table which
is going to be in another scrolling div below.
The problem is if I restrict the with of the containing div to something
less than the with of the table. The table then attempts to crunch the
table width to the least width and thus reduces the table cell widths and
ignores the fixes widht size applied tot he style.
How can I get around this.the simple solution would be to
1. create transparent.gif with size 1x1 pixel
2. To the headers of columns add <img src="http://pics.10026.com/?src=transparent.gif" width=100
height=1>
This will keep your columns to be at least 100 pixels.
PS: There might be easier solutions with CSS. Mine is just a suggestion and
will work with any browser.
George.
"A Question" <q@.qs.com> wrote in message
news:eKEMiamPIHA.1208@.TK2MSFTNGP05.phx.gbl...
> Hi,
> I have a table which I need to display within a div of a fixed width. The
> length of the table exceeds the width of the div which is ok as I can
> make the div scrollable. The problem that I have is that the cells in the
> table must be a fixed with because they need to co-incide with another
> table which is going to be in another scrolling div below.
> The problem is if I restrict the with of the containing div to something
> less than the with of the table. The table then attempts to crunch the
> table width to the least width and thus reduces the table cell widths and
> ignores the fixes widht size applied tot he style.
> How can I get around this.
>
Hi, yes, its a possibility. I have also found that fixing the width of the
table acheives the same thing. Thanks for your help.
"George Ter-Saakov" <gt-nsp@.cardone.com> wrote in message
news:ux8U02mPIHA.292@.TK2MSFTNGP02.phx.gbl...
> the simple solution would be to
> 1. create transparent.gif with size 1x1 pixel
> 2. To the headers of columns add <img src="http://pics.10026.com/?src=transparent.gif" width=100
> height=1>
> This will keep your columns to be at least 100 pixels.
> PS: There might be easier solutions with CSS. Mine is just a suggestion
> and will work with any browser.
> George.
>
> "A Question" <q@.qs.com> wrote in message
> news:eKEMiamPIHA.1208@.TK2MSFTNGP05.phx.gbl...
>

Table Scrolling Problem

Hi,

I have a table which I need to display within a div of a fixed width. The
length of the table exceeds the width of the div which is ok as I can make
the div scrollable. The problem that I have is that the cells in the table
must be a fixed with because they need to co-incide with another table which
is going to be in another scrolling div below.

The problem is if I restrict the with of the containing div to something
less than the with of the table. The table then attempts to crunch the
table width to the least width and thus reduces the table cell widths and
ignores the fixes widht size applied tot he style.

How can I get around this.the simple solution would be to
1. create transparent.gif with size 1x1 pixel
2. To the headers of columns add <img src="http://pics.10026.com/?src=transparent.gif" width=100
height=1>

This will keep your columns to be at least 100 pixels.

PS: There might be easier solutions with CSS. Mine is just a suggestion and
will work with any browser.

George.

"A Question" <q@.qs.comwrote in message
news:eKEMiamPIHA.1208@.TK2MSFTNGP05.phx.gbl...

Quote:

Originally Posted by

Hi,
>
I have a table which I need to display within a div of a fixed width. The
length of the table exceeds the width of the div which is ok as I can
make the div scrollable. The problem that I have is that the cells in the
table must be a fixed with because they need to co-incide with another
table which is going to be in another scrolling div below.
>
The problem is if I restrict the with of the containing div to something
less than the with of the table. The table then attempts to crunch the
table width to the least width and thus reduces the table cell widths and
ignores the fixes widht size applied tot he style.
>
How can I get around this.
>
>


Hi, yes, its a possibility. I have also found that fixing the width of the
table acheives the same thing. Thanks for your help.

"George Ter-Saakov" <gt-nsp@.cardone.comwrote in message
news:ux8U02mPIHA.292@.TK2MSFTNGP02.phx.gbl...

Quote:

Originally Posted by

the simple solution would be to
1. create transparent.gif with size 1x1 pixel
2. To the headers of columns add <img src="http://pics.10026.com/?src=transparent.gif" width=100
height=1>
>
This will keep your columns to be at least 100 pixels.
>
PS: There might be easier solutions with CSS. Mine is just a suggestion
and will work with any browser.
>
George.
>
>
"A Question" <q@.qs.comwrote in message
news:eKEMiamPIHA.1208@.TK2MSFTNGP05.phx.gbl...

Quote:

Originally Posted by

>Hi,
>>
>I have a table which I need to display within a div of a fixed width. The
>length of the table exceeds the width of the div which is ok as I can
>make the div scrollable. The problem that I have is that the cells in the
>table must be a fixed with because they need to co-incide with another
>table which is going to be in another scrolling div below.
>>
>The problem is if I restrict the with of the containing div to something
>less than the with of the table. The table then attempts to crunch the
>table width to the least width and thus reduces the table cell widths and
>ignores the fixes widht size applied tot he style.
>>
>How can I get around this.
>>
>>


>
>

Table Schema Editor

Friends are there any tools/controls in asp.net which can help design create
a table in a database.
thanks!!!There are many databases out there, and many tools for creating database
objects in them. There are some tools as well in VS.Net.

HTH,

Kevin Spencer
Microsoft FrontPage MVP
Internet Developer
http://www.takempis.com
Big things are made up of
lots of Little things.

"sunil" <sunil_godiyal@.yahoo.com> wrote in message
news:eVgxxNAPDHA.3016@.TK2MSFTNGP10.phx.gbl...
> Friends are there any tools/controls in asp.net which can help design
create
> a table in a database.
> thanks!!!
Ah, thanks for the clarification. Hopefully someone here knows of such
third-party apps.

HTH,

Kevin Spencer
Microsoft FrontPage MVP
Internet Developer
http://www.takempis.com
Big things are made up of
lots of Little things.

"sunil" <sunil_godiyal@.yahoo.com> wrote in message
news:u1QzTxAPDHA.1216@.TK2MSFTNGP11.phx.gbl...
> Kevin, Thanks for your reply. Here is my problem. I want the user using
my
> web application to be able to create table using the web interface
provided
> with in the web app. Iam looking for any activex controls or asp.net
> components which can do this.
> Appreciate your help.
> Thanks
>
> "Kevin Spencer" <kevin@.SPAMMERSSUCKtakempis.com> wrote in message
> news:%23S9lmhAPDHA.4024@.tk2msftngp13.phx.gbl...
> > There are many databases out there, and many tools for creating database
> > objects in them. There are some tools as well in VS.Net.
> > HTH,
> > Kevin Spencer
> > Microsoft FrontPage MVP
> > Internet Developer
> > http://www.takempis.com
> > Big things are made up of
> > lots of Little things.
> > "sunil" <sunil_godiyal@.yahoo.com> wrote in message
> > news:eVgxxNAPDHA.3016@.TK2MSFTNGP10.phx.gbl...
> > > Friends are there any tools/controls in asp.net which can help design
> > create
> > > a table in a database.
> > > thanks!!!
> >

table run at server

I want to have an table like this
<table>
if session("userid") <> "" then
<tr><td><droplist></td></tr>
else
<tr><td><hiddeninput></td></tr>
end If

Anybody know how to solve that in .NET and codebehind?Hi,

HTML
=====


<TABLE id="Table1" border="0">
<TR>
<TD>
<asp:DropDownList id="DropDownList1" runat="server">
<asp:ListItem Value="BlahBlah">BlahBlah</asp:ListItem>
</asp:DropDownList>
</TD>
</TR>
</TABLE>

code-behind
===========


Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

If Session("userid") <> "" Then
DropDownList1.Visible = True
Else
DropDownList1.Visible = False
End If

End Sub

HTH
Thanks, but i asked for the tablerow, cause I have labels and so on that don't is supposed to been shown either.

I solved it surfing around like. (My Row that is going to be hidden is Row #3.

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Session("userid") <> "" Then
Table1.Rows(3).Visible = True
Else
Table1.Rows(3)..Visible = False
End If
End Sub

table sizing

I am in my second chapter of trying to learn asp.net and I have my first issue. I am working on an example that asks that I create a HTML table 4x2(RxC) via the web matrix interface. I am not using web matirx, I am with the Visual.NET IDE.
I have inserted a table on the webForm via the HTML tool box, the one under components, and I can not create the 4x2 table. Each time I change the Rows to 4, it keeps getting changed back to 2 when I apply the change.
Why?Vs 03 is notorious for screwing up html code.
Best bet do this:
<table>
<tr>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td>
</td>
<td>
</td>
</tr>
</table>
Alternativly i think theres an insert table command on the menu for vs03, which should let you specify 4x2 and insert you a new table.
Or if the book is working from Web Matrix then maybe you should too, after all its a free download from this site :)
Hope this helps,
Andrew
You may be better off using the web form table, not the one on the html portion of the toolbox.
Use the table menu in the top menu bar.
Zath
Thanks, I am learning quickly the quirks of VS.
Thanks.