can i set the visibility of an item of datalist to false?

M

miladhatam

can i set the visibility of an item of datalist to false ?
for eg :

Item.visible = false;
 
M

miladhatam

i did it myself
protected void Page_Load(object sender, EventArgs e)
{
int range = 2;
int p = Convert.ToInt16(Request["page"].ToString());
if ( p ==0)
p=1;
if (DataList1.Items.Count % range > 0)
{

numeric1.listSize = (DataList1.Items.Count / range) + 1;
}
if (DataList1.Items.Count % range == 0)
{
numeric1.listSize = (DataList1.Items.Count / range);

}
if (p == 1)
{
for (int i = range; i < DataList1.Items.Count ; i++)
{
DataList1.Items.Controls.Clear();
}
}
else
{
for (int i = 0; i < (p-1)*range ; i++)
{
DataList1.Items.Controls.Clear();
}

for (int i = range*(p) ; i < DataList1.Items.Count; i++)
{
DataList1.Items.Controls.Clear();
}

}
}
 
G

George

Just a FYI.
1. this code
if (DataList1.Items.Count % range > 0)
{

numeric1.listSize = (DataList1.Items.Count / range) + 1;
}
if (DataList1.Items.Count % range == 0)
{
numeric1.listSize = (DataList1.Items.Count / range);

}
Can be simplified to
numeric1.listSize = (DataList1.Items.Count + range-1) / range;

2. This code
for (int i = range; i < DataList1.Items.Count ; i++)
{
DataList1.Items.Controls.Clear();
}

Can be written without brackets. It's matter of preference but i think it's
easier to read

for (int i = range; i < DataList1.Items.Count ; i++)
DataList1.Items.Controls.Clear();


George



i did it myself
protected void Page_Load(object sender, EventArgs e)
{
int range = 2;
int p = Convert.ToInt16(Request["page"].ToString());
if ( p ==0)
p=1;
if (DataList1.Items.Count % range > 0)
{

numeric1.listSize = (DataList1.Items.Count / range) + 1;
}
if (DataList1.Items.Count % range == 0)
{
numeric1.listSize = (DataList1.Items.Count / range);

}
if (p == 1)
{
for (int i = range; i < DataList1.Items.Count ; i++)
{
DataList1.Items.Controls.Clear();
}
}
else
{
for (int i = 0; i < (p-1)*range ; i++)
{
DataList1.Items.Controls.Clear();
}

for (int i = range*(p) ; i < DataList1.Items.Count; i++)
{
DataList1.Items.Controls.Clear();
}

}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top