I have Table named PRODUCTS , that have 4 column productid, productprice,productname & discount( type numeric(18,0)) .. i am using datalist with itemtemplate that have 4 label to display all ..
i am binding datalist on pageload, now i want that Label4 with "discount" should only visible for those product that have discount , otherwise it remains hidden,
problem in my code is that when i run it , label becomes invisible for all products whether they have discount or not . kindly guide me..
here is my code i am using for it:
ds1 is my dataset
foreach (DataListItem item in DataList1.Items)
{
for (int i = 0; i <= ds1.Rows.Count - 1; i++)
{
double[] arr = new double[ds1.Rows.Count];
double temp = double.Parse(ds1.Rows[i]["discount"].ToString());
arr[i] = temp;
Label lbl = item.FindControl("Label4") as Label;
if (arr[i] == 0)
lbl.Visible=false;
}
}