Friday, 13 July 2012

user control save

user control code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Swash.Objects;
using Swash.BusinessLayer;

namespace Website.App_WebControls.UAMS_UserControls
{
    public partial class AMS_UCUSingleSelection : System.Web.UI.UserControl
    {
        public delegate void SingleSelect(List<AMS_UCUSelection> SingleRadList);
        public event SingleSelect SelectEvent;
        protected void Page_Load(object sender, EventArgs e)
        {
           
        }
        public void FillRadioList(AMS_UCUSelection objSelect)
        {
            lblHeader.Text = objSelect.HeaderText;
            RadSelect.DataSource = UERPManagement.GetInstance.GetAllSelectionDetails(objSelect);
            RadSelect.DataTextField = "Text";
            RadSelect.DataValueField = "Value";
            RadSelect.DataBind();
        }
        protected void ImgBtnAdd_Click(object sender, ImageClickEventArgs e)
        {
            List<AMS_UCUSelection> SingleChk = new List<AMS_UCUSelection>();
            foreach(ListItem li in RadSelect.Items)
            {
                if (li.Selected)
                {
                    AMS_UCUSelection obj = new AMS_UCUSelection();
                    obj.Text = li.Text;
                    obj.Value = li.Value;
                    SingleChk.Add(obj);
                    break;
                }
            }
           
            if (this.SelectEvent != null)
            {
                this.SelectEvent(SingleChk);
            }
        }
    }
}

page code:
 AMS_UCUSelection objSelect = new AMS_UCUSelection();
            objSelect.HeaderText = "Category List [Single Selection]";
            objSelect.TableName = "ams.AMS_Category";
            objSelect.Text = "CategoryName";
            objSelect.Value = "CategoryId";
            CategorySelect.FillRadioList(objSelect);

No comments:

Post a Comment