Tuesday, January 3, 2012

LoouKup Program with Asp.Net server Controls.

SPWeb currentWeb = SPControl.GetContextWeb(Context);SPList category = currentWeb.Lists["Category"];
                    SPQuery sQuery = new SPQuery();
                    sQuery.Query = "<OrderBy><FieldRef Name='ID' Ascending='False' /></OrderBy>";
                    SPListItemCollection categoryList = category.GetItems(sQuery);
                    ddlCategory = new DropDownList();
                    ddlCategory.ID = "ddlCategory";
                    if (categoryList.Count > 0)
                    {
                        foreach (SPListItem sQueryItem in categoryList)
                        {
                            ddlCategory.Items.Add(sQueryItem.Title.ToString());
                        }
                    }
                    this.Controls.Add(ddlCategory);
                    ddlCategory.Items.Insert(0, "Select Category");
                    chkCategory = new CheckBoxList();
                    chkCategory.ID = "chkCategory";
                    if (categoryList.Count > 0)
                    {
                        foreach (SPListItem sQueryItemCheckBox in categoryList)
                        {
                            chkCategory.Items.Add(sQueryItemCheckBox.Title.ToString());
                        }
                    }
                    this.Controls.Add(chkCategory);
                    rbCategory = new RadioButtonList();
                    rbCategory.ID = "rbCategory";
                    if (categoryList.Count > 0)
                    {
                        foreach (SPListItem sQueryItemRadioButton in categoryList)
                        {
                            rbCategory.Items.Add(sQueryItemRadioButton.Title.ToString());
                        }
                    }
                    this.Controls.Add(rbCategory);

No comments:

Post a Comment