Пример #1
0
 void LoadCategoryGroup(DropDownList ddl)
 {
     Category cat = new Category();
     ddl.Items.Clear();
     DataTable dt1 = cat.SelectCategoryGroup();
     ListItem listItem = new ListItem();
     listItem.Text = "<Select Category Group>";
     listItem.Value = "0";
     //listItem.Attributes.Add("style", "background-Black:white;color:White");
     ddl.Items.Add(listItem);
     for (int i = 0; i < dt1.Rows.Count; i++)
     {
         listItem = new ListItem();
         listItem.Text = dt1.Rows[i]["CategoryGroupName"].ToString();
         listItem.Value = dt1.Rows[i]["CategoryGroupId"].ToString();
         //listItem.Attributes.Add("style", "background-color:Black;color:white");
         ddl.Items.Add(listItem);
     }
 }
Пример #2
0
        void LoadCategory()
        {
            objCategory = new Category();
            dt = objCategory.SelectCategoryGroup();

            if (dt.Rows.Count > PageSize)
                tblPaging.Visible = true;
            else
                tblPaging.Visible = false;

            if (dt.Rows.Count > 0)
            {
                if (tblPaging.Visible == true)
                {
                    // Setting viewstate for TotalRecords

                    LabelTotalRecords.Text = dt.Rows.Count.ToString();

                    // Setting viewstate for TotalPages

                    if (int.Parse(LabelTotalRecords.Text) % PageSize > 0)

                        // If page size is not exactly divisible by total records

                        ViewState["TotalPages"] = int.Parse(LabelTotalRecords.Text) / PageSize;

                    else

                        // If page is exactly divisible by total records

                        ViewState["TotalPages"] = int.Parse(LabelTotalRecords.Text) / PageSize - 1;

                    ViewState["dataTable"] = dt;

                    if (!object.Equals(dt, null))
                    {

                        BindList(ManagePaging(dt));

                    }
                }
                else
                {
                    DataList1.DataSource = dt;
                    DataList1.DataBind();
                }
            }
            else
                PagingRow.Visible = false;
        }