Hello All,

I am binding a datalist to some table 0 of a dataset from the database. When I check the number of rows in the dataset table 0 it's coming as 129 but when I check the count of the datalist items(using Datalist_Name.Items.Count) inside the datalist item created event I am getting a maximum count of 128.Due, to this I am unable to assign values to the last label control(last as in the last row) present inside the datalist dynamically. I am not sure where I am going wrong. I even tried to replicate the same code inside the ItemDataBound event but even then I am getting the same error.Any ideas will be greatly appreciated.


Thanks.

personally when populating from a dataset to any other type of container I use the following loop to ensure I get all the values. Since you didn't include any code to see what your current binding logic looks like I'll give an example below:

for (int a = 0; a < dataSetName.Tables["0"].Rows.Count; a++)
{
    DataRow dataRowName = dataSetName.Tables["0"].Rows[a];
    insert data item setup here
    dataListName.Items.Add(dataItemName);
}

Once the loop terminates all items from the original dataset table should be within the new datalist. If the list is only to be populated once then I would ensure that the procedure for this load is within a segment such as:

if (Page.IsPostBack == false)
{
    datalistGenerator();
}

Or... failing that, include a

dataListName.Items.Clear();

line pre-loading to ensure that you don't duplicate your entries.

Hope this helps, please mark solved if it does :)

personally when populating from a dataset to any other type of container I use the following loop to ensure I get all the values. Since you didn't include any code to see what your current binding logic looks like I'll give an example below:

for (int a = 0; a < dataSetName.Tables["0"].Rows.Count; a++)
{
    DataRow dataRowName = dataSetName.Tables["0"].Rows[a];
    insert data item setup here
    dataListName.Items.Add(dataItemName);
}

Once the loop terminates all items from the original dataset table should be within the new datalist. If the list is only to be populated once then I would ensure that the procedure for this load is within a segment such as:

if (Page.IsPostBack == false)
{
    datalistGenerator();
}

Or... failing that, include a

dataListName.Items.Clear();

line pre-loading to ensure that you don't duplicate your entries.

Hope this helps, please mark solved if it does :)

Thanks for the reply.I figured out the issue with my code :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.