It was hard to find the correct question topic. Well, let me elaborate more. I’m making a barcode generator simple webapp. It is for our warehouse team.
I made a class named SqlComm where I handle all SQL connection related thing. Then, I have a query (the query is just about counting a column where some Date in between). I use the query for setting the array size. Later, it loops through a for cycle and adds each new label to a placeholder. Sadly, the placeholder is not showing my new labels just created.
c# (codebehing)
int index = 0;
int iLength = 0;
dt = SqlComm.SqlDataTable("SELECT [Lenum] FROM [SUIDonMachineTable] WHERE MachineTimestamp BETWEEN CONVERT(datetime,'"+strDayFrom+"', 121) AND CONVERT(datetime,'"+strDayTo+"', 121) AND Station ='NG08NX1BT'");
object obj = new object();
obj = SqlComm.SqlReturn("SELECT COUNT (Lenum) FROM [SUIDonMachineTable] WHERE MachineTimestamp BETWEEN CONVERT(datetime,'"+strDayFrom+"', 121) AND CONVERT(datetime,'"+strDayTo+"', 121) AND Station ='NG08NX1BT'");
iLength = Convert.ToInt32(obj);
Label[] labels = new Label[iLength];
for (index = 0; index == iLength; index++)
{
labels[index] = new Label();
labels[index].Text = (string)dt.Rows[index]["Lenum"];
PH.Controls.Add(labels[index]);
}
asp.net (placeholder part)
<asp:PlaceHolder ID="PH" runat="server"></asp:PlaceHolder>
Try it.