Friday, 13 September 2013

Bind Gridview Using Jquery



Create a new page
<link href="/DataTables/media/css/demo_table.css"
    rel="stylesheet" type="text/css" />
<link href="/DataTables/media/css/demo_page.css"
    rel="stylesheet" type="text/css" />
<link href="/media/css/jquery.dataTables.css"
    rel="stylesheet" type="text/css" />
<script src="/DataTables/media/js/jquery.dataTables.js"
    charset="utf-8" type="text/javascript"></script>









<script type="text/javascript">
    var temp;


    $(document).ready(function () {

        $("input[id$=Remove]").hide();
        $("input[id$=Remove]").click(function () {

            ddlprod = 0;
            ddlActive = 0;
           $("select[id$=ddlProduct]").val($("select[id$=ddlProduct]option:first").val());
           $("select[id$=ddlActive]").val($("select[id$=ddlProduct]option:first").val());

            GetRecord(ddlprod, ddlActive);

            $("input[id$=Remove]").hide();
            return false;
        });
        $("span[id*=dnnTITLE_titleLabel]").hide();
        //$("select[id$=ddlProduct]").val($("select[id$=ddlProduct]option:first").val());
        // $("select[id$=ddlActive]").val($("select[id$=ddlProduct]option:Third").val());
        var ddlprod;
        var ddlActive;

       
        //$("#image1").hover(function(){ $(this).find("#Toggl").toggle("scale"{}1000); return false; });

        $("input[id$=btnsearch]").click(function () {
           
            ddlprod = $("select[id$=ddlProduct]").val();
            ddlActive = $("select[id$=ddlActive]").val();
            if (ddlActive != 3 && ddlprod != 0) {

                GetRecord(ddlprod, ddlActive);
                $("input[id$=Remove]").show();
            }
            return false;
        });


        ddlprod = 0;
        ddlActive = 0;
        GetRecord(ddlprod, ddlActive);

    });

    function GetRecord(ddlprod, ddlActive) {
      
        var strinner, tableString = '', tableclose = "</table>"
        tableString = ""; tablename = "";
        $.post("/AllEvendData.ashx", { ProductID: null, DDlprod: ddlprod, DDlActive: ddlActive }, function (result) {
            $("#tbldynamicdata").html("");

            var SubjectsResult = jQuery.parseJSON(result);
            var div_Hdata = "<thead><tr><th style='width:300px;border: 1px solid grey;'>Webinar Name</th><th style='width:75px;border: 1px solid grey;'>Product</th><th style='width:75px;border: 1px solid grey;'>Status</th><th style='width:0px;border: 1px solid grey;'>Active/Archived</th><th style='width:70px;border: 1px solid grey;'>Assigned Portals/No. of Portals</th><th style='width:75px;border: 1px solid grey;'>Clone</th><th style='width:75px;border: 1px solid grey;'>Actions</th></tr></thead><tbody>";
            $(div_Hdata).appendTo("#tbldynamicdata");
            if (SubjectsResult.length > 0) {
                var count = SubjectsResult.length;


                for (i = 0; i < SubjectsResult.length; i++) {
                    var EventID = SubjectsResult[i].EventID;
                    var EventName = SubjectsResult[i].EventName;
                    var Product = SubjectsResult[i].Product;
                    var Status = SubjectsResult[i].Active;
                    var Portals = SubjectsResult[i].TotalClient;
                    var assignedportal = SubjectsResult[i].Portals1;
                    var Clone = 'Clone';
                    Active = SubjectsResult[i].Active

                    if (Active == true) {
                        var Active = 'active.png';
                        var Inuse = 'Yes';

                    }
                    else {
                        var Active = 'de-active.png';
                        var Inuse = 'No';
                    }

                    if (Portals == "N/A") {
                        if (assignedportal == "N/A") {
                            var div_data = "<tr><td style='width:300px;'>" + EventName + "</td><td style='width:75px;'>" + Product + "</td><td style='width:50px;'><select><option value='0'>Current</option><option value='1'>Recorded</option><option value='2'>Featured</option></select></td><td style='width:75px;'><a id=" + Active + " href='' onclick='javascript:return UpdateActDeact(" + EventID + ")' ><img src='/DesktopModules/Redbarn-ManageEvent/images/" + Active + "' alt='alt text' style='border:none;height:20px;width:20px;' title='Active' /></a></td><td>0/0</td><td><a id=" + EventID + " href='' class='deleting' onclick='javascript:return check1(\"" + EventID + "\",\"" + EventName + "\")'><img src='/DesktopModules/Redbarn-ManageEvent/images/copy-icon.png' alt='alt text' style='border:none;height:20px;width:20px;' title='Clone' /></a></td><td style='width:75px;'><a id=" + EventID + " class='btnedit' href='' onclick='javascript:return edit(" + EventID + ")' ><img src='/DesktopModules/Redbarn-ManageEvent/images/new edit-icon.png' alt='alt text' style='border:none;height:20px;width:20px;' title='Edit' /></a>&nbsp&nbsp<a id=" + EventID + " href='' class='deleting' onclick=' javascript:return check(" + EventID + ")'><img src='/DesktopModules/Redbarn-ManageEvent/images/DeleteRed.png' alt='alt text' style='border:none;height:20px;width:20px;' title='Delete' /></a></td></tr></tbody>";
                            $(div_data).appendTo("#tbldynamicdata");
                        }
                        else {
                            var div_data = "<tr><td style='width:300px;'>" + EventName + "</td><td style='width:75px;'>" + Product + "</td><td style='width:75px;'><select><option value='0'>Current</option><option value='1'>Recorded</option><option value='2'>Featured</option></select></td><td style='width:75px;'><a id=" + Active + " href='' onclick='javascript:return UpdateActDeact(" + EventID + ")' ><img src='/DesktopModules/Redbarn-ManageEvent/images/" + Active + "' alt='alt text' style='border:none;height:20px;width:20px;' title='Active' /></a></td><td>0/<a id=" + EventID + " href='' class='osx' onclick=' javascript:return checkDia123(" + EventID + "," + Portals + ")'>" + Portals + "</a></td><td><a id=" + EventID + " href='' class='deleting' onclick='javascript:return check1(\"" + EventID + "\",\"" + EventName + "\")'><img src='/DesktopModules/Redbarn-ManageEvent/images/copy-icon.png' alt='alt text' style='border:none;height:20px;width:20px;' title='Clone' /></a></td><td style='width:75px;'><a id=" + EventID + " class='btnedit' href='' onclick='javascript:return edit(" + EventID + ")' ><img src='/DesktopModules/Redbarn-ManageEvent/images/new edit-icon.png' alt='alt text' style='border:none;height:20px;width:20px;' title='Edit' /></a>&nbsp&nbsp<a id=" + EventID + " href='' class='deleting' onclick=' javascript:return check(" + EventID + ")'><img src='/DesktopModules/Redbarn-ManageEvent/images/DeleteRed.png' alt='alt text' style='border:none;height:20px;width:20px;' title='Delete' /></a></td></tr></tbody>";
                            $(div_data).appendTo("#tbldynamicdata");
                        }
                       
                    }
                    else {


                        if (assignedportal == "N/A") {

                            var div_data = "<tr><td style='width:300px;'>" + EventName + "</td><td style='width:75px;'>" + Product + "</td><td style='width:75px;'><select><option value='0'>Current</option><option value='1'>Recorded</option><option value='2'>Featured</option></select></td><td style='width:75px;'><a id=" + Active + " href='' onclick='javascript:return UpdateActDeact(" + EventID + ")' ><img src='/DesktopModules/Redbarn-ManageEvent/images/" + Active + "' alt='alt text' style='border:none;height:20px;width:20px;' title='Active' /></a></td><td>0/<a id=" + EventID + " href='' class='osx' onclick=' javascript:return checkDia123(" + EventID + "," + Portals + ")'>" + Portals + "</a></td><td><a id=" + EventID + " href='' class='deleting' onclick='javascript:return check1(\"" + EventID + "\",\"" + EventName + "\")'><img src='/DesktopModules/Redbarn-ManageEvent/images/copy-icon.png' alt='alt text' style='border:none;height:20px;width:20px;' title='Clone' /></a></td><td style='width:75px;'><a id=" + EventID + " class='btnedit' href='' onclick='javascript:return edit(" + EventID + ")' ><img src='/DesktopModules/Redbarn-ManageEvent/images/new edit-icon.png' alt='alt text' style='border:none;height:20px;width:20px;' title='Edit' /></a>&nbsp&nbsp<a id=" + EventID + " href='' class='deleting' onclick=' javascript:return check(" + EventID + ")'><img src='/DesktopModules/Redbarn-ManageEvent/images/DeleteRed.png' alt='alt text' style='border:none;height:20px;width:20px;' title='Delete' /></a></td></tr></tbody>";
                            $(div_data).appendTo("#tbldynamicdata");
                        }
                        else {
                            var div_data = "<tr><td style='width:300px;'>" + EventName + "</td><td style='width:75px;'>" + Product + "</td><td style='width:75px;'><select><option value='0'>Current</option><option value='1'>Recorded</option><option value='2'>Featured</option></select></td><td style='width:75px;'><a id=" + Active + " href='' onclick='javascript:return UpdateActDeact(" + EventID + ")' ><img src='/DesktopModules/Redbarn-ManageEvent/images/" + Active + "' alt='alt text' style='border:none;height:20px;width:20px;' title='Active' /></a></td><td><a id=" + EventID + " href='' class='osx' onclick=' javascript:return checkDia(" + EventID + "," + Portals + ")'>" + assignedportal + "</a>/<a id=" + EventID + " href='' class='osx' onclick=' javascript:return checkDia123(" + EventID + "," + Portals + ")'>" + Portals + "</a></td><td><a id=" + EventID + " href='' class='deleting' onclick='javascript:return check1(\"" + EventID + "\",\"" + EventName + "\")'><img src='/DesktopModules/Redbarn-ManageEvent/images/copy-icon.png' alt='alt text' style='border:none;height:20px;width:20px;' title='Clone' /></a></td><td style='width:75px;'><a id=" + EventID + " class='btnedit' href='' onclick='javascript:return edit(" + EventID + ")' ><img src='/DesktopModules/Redbarn-ManageEvent/images/new edit-icon.png' alt='alt text' style='border:none;height:20px;width:20px;' title='Edit' /></a>&nbsp&nbsp<a id=" + EventID + " href='' class='deleting' onclick=' javascript:return check(" + EventID + ")'><img src='/DesktopModules/Redbarn-ManageEvent/images/DeleteRed.png' alt='alt text' style='border:none;height:20px;width:20px;' title='Delete' /></a></td></tr></tbody>";
                            $(div_data).appendTo("#tbldynamicdata");
                        }
                    }
                }

                $('#tbldynamicdata').dataTable({
                    //                    "sScrollY": "300px",
                    "bPaginate": true,
                    "bDestroy": true
                });
            }
            else {
                $('#tbldynamicdata').dataTable({
                    //                    "sScrollY": "300px",
                    "bPaginate": false,
                    "bDestroy": true
                });
            }

        });
      
    }
    function check(EventID) {
        if (confirm("Are you sure you want to delete?")) {

          
            var command = 'Delete_Product';


            $.post("/AllEvendData.ashx", { ProductID: EventID, command: command }, function (result) {
                var ddlprod;
                var ddlActive;
                ddlprod = $("select[id$=ddlProduct]").val();
                ddlActive = $("select[id$=ddlActive]").val();
                if (ddlActive != 3 && ddlprod != 0) {
                   
                    GetRecord(ddlprod, ddlActive);
                }
                else {
                    ddlprod = 0;
                    ddlActive = 0;
               GetRecord(ddlprod, ddlActive);
                }

            });

        }
      return false;
    }
   

    function edit(EventID) {
        var url = '<%=this.urlsend %>';
      
        var command = 'Edit_Product';
        //url = url.replace("CEID", EventID);
        var result = url + "?EID=" + EventID;
       
        //window.location.href = url;
        window.location.replace(result);
     
        return  false;

    }
    function UpdateActDeact(EventID) {
      var  LastUpdatedBy = '<%=userid %>';
       var command = 'UpdateActDeact_Product';
       $.post("/AllEvendData.ashx", { ProductID: EventID, LastUpdatedBy: LastUpdatedBy, command: command }, function (result) {
            // window.location.href = window.location.href;
           var ddlprod;
           var ddlActive;
           ddlprod = $("select[id$=ddlProduct]").val();
           ddlActive = $("select[id$=ddlActive]").val();
           if (ddlActive != 3 && ddlprod != 0) {

               GetRecord(ddlprod, ddlActive);
           }
           else {
               ddlprod = 0;
               ddlActive = 0;
               GetRecord(ddlprod, ddlActive);
           }
        });
        return false;
    }

    function checkDia(EventID, Portal) {
     
        var url = '<%=this.ClintPortalUrl %>';
       
        if (Portal != "N/A") {
            var command = 'Edit_Product';
            var result = url + "?EID=" + EventID;
            window.location.replace(result);
            return false;
        }
    }
    function checkDia123(EventID, Portal) {

        var url = '<%=this.ClintPortalUrl %>';

        if (Portal != "N/A") {
            var command = 'Edit_Product';
            var result = url + "?CID=" + EventID;
            window.location.replace(result);
            return false;
        }
    }

    function check1(EventID, EventName) {
      
      
        if (confirm("Are you sure you want to clone?")) {
           
                var command = 'Insert_Product';


                $.post("/AllEvendData.ashx", { ProductID: EventID, command: command }, function (result) {
                    //  var ddlprod;
                    var ddlActive;
                    ddlprod = $("select[id$=ddlProduct]").val();
                    ddlActive = $("select[id$=ddlActive]").val();

                    if (ddlActive != 3 && ddlprod != 0) {

                        GetRecord(ddlprod, ddlActive);
                    }
                    else {
                        ddlprod = 0;
                        ddlActive = 0;
                        GetRecord(ddlprod, ddlActive);
                    }

                });

                if (alert("Clone Webinar\n\n\n The webinar clone was successful.\n\n The webinar name is " + EventName + " - Clone")) {
                }
                return false;
            }
           
    }
</script>
<style type="text/css">
  
 .linkbtn
    {
        float: right;
    }
    .linkbtn1
    {
        float: right;
        margin-right: 10px;
    }</style>
<fieldset id="MngCaption">
   <legend style="font-size: X-Large; font-family: Arial; font-weight: bold;">Manage Events</legend>
<table width="100%">
    <tr>
       
       
       
<td width="25%"><asp:Button ID="btnCreate" runat="server" Text="Create New Webinar"
    onclick="btnCreate_Click" class="buttonsave"/>
</td>

    </tr>
   
</table>

<table id="Tabsearch"><tr>
<td width="25%">
            <asp:DropDownList ID="ddlProduct" runat="server" class="dropdown"
        Style="border: 1px solid #999999; border-radius: 3px 3px 3px 3px; padding: 3px;"
        Width="100%" AppendDataBoundItems="True">
                     <asp:ListItem Value="0">Select Product</asp:ListItem>
                  </asp:DropDownList>

        </td>
        <td width="25%">
            <asp:DropDownList ID="ddlActive" runat="server" class="dropdown"
        Style="border: 1px solid #999999; border-radius: 3px 3px 3px 3px; padding: 3px;"
        Width="100%" AppendDataBoundItems="True">
<asp:ListItem Value="3">Select</asp:ListItem>
                    <asp:ListItem Value="0">Archived</asp:ListItem>
<asp:ListItem Value="1">Active</asp:ListItem>
<asp:ListItem Value="2">Both</asp:ListItem>


                  </asp:DropDownList>
        </td><td width="15%" valign="top">
            <asp:Button ID="btnsearch" runat="server" Text="Search" class="buttonsave" />
           
        </td><td width="35%" valign="top"><asp:Button ID="Remove" runat="server" Text="Clear"
    class="buttonsave" /></td></tr></table>
<div class="PDf_tab">
<asp:LinkButton ID="LbtnPDF" runat="server" CssClass="linkbtn" OnClick="LbtnPDF_Click"></asp:LinkButton>
    <asp:LinkButton ID="LbtnCSV" runat="server" CssClass="linkbtn1" OnClick="LbtnCSV_Click"></asp:LinkButton>
   </div>



<table id="tbldynamicdata" class="mGrid">
</table>
</fieldset>


<b>On .cs page</b>
public int userid;
        public string urlsend;
        public string ClintPortalUrl;
        ManageEventInfo obj = new ManageEventInfo();
        ManageEventContriller obj1 = new ManageEventContriller();
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                userid = this.UserId;
                urlsend = Globals.NavigateURL(PortalSettings.ActiveTab.TabID, "CreateNewWebinar", "mid=" + ModuleId);
                //urlsend = Globals.NavigateURL(PortalSettings.ActiveTab.TabID, "CreateNewWebinar", "mid=" + ModuleId, "EID=CEID");
                //ClintPortalUrl = Globals.NavigateURL(PortalSettings.ActiveTab.TabID, "ClintPortal", "mid=" + ModuleId, "EID=CEID");
                ClintPortalUrl = Globals.NavigateURL(PortalSettings.ActiveTab.TabID, "ClintPortal", "mid=" + this.ModuleId);
                //url = Globals.NavigateURL(PortalSettings.ActiveTab.TabID, "CreateNewWebinar", "mid=" + this.ModuleId);
                if (!IsPostBack)
                {
                    DataSet ds = new DataSet();
                    ds = obj1.getallproduct();

                    ddlProduct.DataSource = ds.Tables[0];
                    ddlProduct.DataValueField = "ProductID";
                    ddlProduct.DataTextField = "ProductName";
                    ddlProduct.DataBind();




                }
                else { }

            }
            catch (Exception ex)
            {
                Exceptions.ProcessModuleLoadException(this, ex);
            }
        }

 protected void btnCreate_Click(object sender, EventArgs e)
        {
            Response.Redirect(Globals.NavigateURL(PortalSettings.ActiveTab.TabID, "CreateNewWebinar", "mid=" + this.ModuleId));
        }
        protected void LbtnPDF_Click(object sender, EventArgs e)
        {
            try
            {
                DataSet ds = new DataSet();
                if (ddlProduct.SelectedIndex != 0 || ddlActive.SelectedIndex != 3)
                {
                    int DdlProd = ddlProduct.SelectedIndex;
                    int DdlActive = ddlActive.SelectedIndex;
                    ds = obj1.getallEvent(DdlProd, DdlActive);
                }
                else
                {
                    int DdlProd = 0;
                    int DdlActive = 0;
                    ds = obj1.getallEvent(DdlProd, DdlActive);
                }
                DataTable dt = ds.Tables[0];
                DataView view = new DataView(dt);
                DataTable table = view.ToTable(true, "EventName", "ProductName", "Active");
                DataTable table2 = new DataTable();
                table2.Columns.Add("Webinar Name", typeof(string));
                table2.Columns.Add("Product", typeof(string));

                table2.Columns.Add("Active", typeof(string));

                foreach (DataRow dr in table.Rows)
                {
                    UserInfo objUserInfo = new UserInfo();

                    //if (dr["LastUpdatedBy"] != null)
                    //{
                    //    objUserInfo = UserController.GetUserById(this.PortalId, Convert.ToInt32(dr["LastUpdatedBy"]));
                    string name = "";
                    string active = "";
                    if (objUserInfo != null)
                    {
                        name = objUserInfo.Username;
                    }
                    if ((dr["Active"]).ToString() == "True")
                    {
                        active = "Active";
                    }
                    else
                    {
                        active = "Archived";
                    }

                    //dr["LastUpdatedBy"] = name;
                    table2.Rows.Add(dr["EventName"], dr["ProductName"], active);
                    //}
                }
                Response.ContentType = "application/pdf";
                Response.AddHeader("content-disposition", "attachment;filename=PurchaseOrderDetails.pdf");
                Response.Cache.SetCacheability(HttpCacheability.NoCache);
                StringWriter sw = new StringWriter();
                HtmlTextWriter hw = new HtmlTextWriter(sw);
                GridView gridview1 = new GridView();
                gridview1.AllowPaging = false;
                gridview1.DataSource = table2;
                gridview1.DataBind();
                gridview1.RenderControl(hw);
                gridview1.HeaderRow.Style.Add("width", "15%");
                gridview1.HeaderRow.Style.Add("font-size", "10px");
                gridview1.Style.Add("text-decoration", "none");
                gridview1.Style.Add("font-family", "Arial, Helvetica, sans-serif;");
                gridview1.Style.Add("font-size", "8px");
                StringReader sr = new StringReader(sw.ToString());
                Document pdfDoc = new Document(PageSize.A2, 7f, 7f, 7f, 0f);
                HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
                PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
                pdfDoc.Open();
                htmlparser.Parse(sr);
                pdfDoc.Close();
                Response.Write(pdfDoc);
                Response.End();
            }
            catch (Exception ex)
            {
                string ErrMsg = ex.Message;
            }
        }
        private string ExportToCSVFile(DataTable dtTable)
        {
            UserInfo objUserInfo = new UserInfo();
            StringBuilder sbldr = new StringBuilder();
           
                DataView view = new DataView(dtTable);
                DataTable table = view.ToTable(false,"EventName", "ProductName", "Active");
                DataTable table2 = new DataTable();
               
                table2.Columns.Add("Webinar Name", typeof(string));
                table2.Columns.Add("Product", typeof(string));

                table2.Columns.Add("Active", typeof(string));
                if (dtTable.Rows.Count > 0)
                {
                foreach (DataRow dr in table.Rows)
                {




                    string active = "";

                    if ((dr["Active"]).ToString() == "True")
                    {
                        active = "Active";
                    }
                    else
                    {
                        active = "Archived";
                    }


                    //dr["LastUpdatedBy"] = name;
                    table2.Rows.Add(dr["EventName"], dr["ProductName"], active);


                }

                if (table2.Columns.Count != 0)
                {
                    foreach (DataColumn col in table2.Columns)
                    {
                        sbldr.Append(col.ColumnName + ',');
                    }
                    sbldr.Append("\r\n");
                    foreach (DataRow row in table2.Rows)
                    {

                        foreach (DataColumn column in table2.Columns)
                        {
                            sbldr.Append(row[column].ToString() + ',');
                        }
                        sbldr.Append("\r\n");
                    }
                }
            }
            return sbldr.ToString();
        }
        protected void LbtnCSV_Click(object sender, EventArgs e)
        {
            DataSet ds = new DataSet();
            DataTable dt = new DataTable();
            if (ddlProduct.SelectedIndex != 0 || ddlActive.SelectedIndex != 3)
            {
                int DdlProd = ddlProduct.SelectedIndex;
                int DdlActive = ddlActive.SelectedIndex;
                ds = obj1.getallEvent(DdlProd, DdlActive);
            }
            else
            {
                int DdlProd = 0;
                int DdlActive = 0;
                ds = obj1.getallEvent(DdlProd, DdlActive);
            }

            dt = ds.Tables[0];
            Response.ContentType = "Application/CSV";
            Response.AddHeader("content-disposition", "attachment;filename=ProductDetails.csv");

            Response.Write(ExportToCSVFile(dt));
            Response.End();


        }
<b>on .Ashx page<b>

public class AllEvendData : IHttpHandler
    {
        System.Collections.Generic.List<ManageEventForGried> details = new System.Collections.Generic.List<ManageEventForGried>();
        ManageEventContriller obuser = new ManageEventContriller();
        public void ProcessRequest(HttpContext context)
        {
            if (context.Request["command"] != null)
            {
                if (context.Request["command"].ToString() == "Delete_Product")
                {
                   
                    int pid = Convert.ToInt32(context.Request["ProductID"].ToString());
                    DeleteRow(pid);
                    ///string result = GetAllProducts();
                   // context.Response.Write(result);
                }
                if (context.Request["command"].ToString() == "Insert_Product")
                {

                    int pid = Convert.ToInt32(context.Request["ProductID"].ToString());
                    insertEvent(pid);
                    //string result = GetAllProducts();
                    //context.Response.Write(result);
                }
                if (context.Request["command"].ToString() == "Edit_Product")
                {
                    string url = context.Request["url"].ToString();
                    int pid = Convert.ToInt32(context.Request["ProductID"].ToString());
                    string result = url + "?EID=" + pid;
                    //context.Response.Write(cornerUrl);
                    //string result = GetAllProducts();
                    context.Response.Write(result);
                }
                if (context.Request["command"].ToString() == "UpdateActDeact_Product")
                {

                    int pid = Convert.ToInt32(context.Request["ProductID"].ToString());
                    int userid = Convert.ToInt32(context.Request["LastUpdatedBy"].ToString());
                    int result = UpdateEventActDeact(pid, userid);
                    context.Response.Write(result);
                }
                if (context.Request["command"].ToString() == "Clint_Portal")
                {


                    int EventId = Convert.ToInt32(context.Request["ProductID"].ToString());
                    int CID = Convert.ToInt32(context.Request["CID"].ToString());
                    string result = GetClintPortal(EventId,CID);
                    context.Response.Write(result);
                }
                if (context.Request["command"].ToString() == "Delete_CLintPortal")
                {


                    int CID = Convert.ToInt32(context.Request["ProductID"].ToString());
                    int EID = Convert.ToInt32(context.Request["EventID"].ToString());
                    int result = DeletePortalClient(CID, EID);
                    context.Response.Write(result);
                }
                if (context.Request["command"].ToString() == "ADD_CLINT")
                {


                    int CID = Convert.ToInt32(context.Request["ProductID"].ToString());
                    int EID = Convert.ToInt32(context.Request["EventID"].ToString());
                  
                    int result = UpdatePortalClient(CID,EID);
                    context.Response.Write(result);
                }
                if (context.Request["command"].ToString() == "Select_Image")
                {
                    int PID = Convert.ToInt32(context.Request["ProductID"].ToString());
                    int EID = Convert.ToInt32(context.Request["EventID"].ToString());
                    int Forcall = Convert.ToInt32(context.Request["forcall"].ToString());
                    if (Forcall == 0)
                    {
                        string result1 = DeletegetallPresenter(PID,EID);
                       
                    }
                    string result = getallPresenter();
                    context.Response.Write(result);
                }
               
               
            }

            else
            {
                context.Response.ContentType = "text/plain";
                int DdlProd = Convert.ToInt32(context.Request["DDlprod"].ToString());
                int DdlActive = Convert.ToInt32(context.Request["DDlActive"].ToString());
              
                string result = GetAllProducts(DdlProd,DdlActive);
                context.Response.Write(result);
            }
        }

        public string DeletegetallPresenter(int PID,int EID)
        {

            int ds = obuser.DeletegetallPresenter(PID,EID);
         
            JavaScriptSerializer oSerializer = new JavaScriptSerializer();
            return oSerializer.Serialize(ds);

        }
        public string getallPresenter()
        {
      
            DataSet ds = obuser.getallPresenter();
           DataTable dt = ds.Tables[0];
           
            foreach (DataRow dtrow in dt.Rows)
            {
                ManageEventForGried user = new ManageEventForGried();
                user.EventID = Convert.ToInt32(dtrow["PresenterID"].ToString());
                user.EventName = dtrow["Photo"].ToString();
                user.name = dtrow["Name"].ToString();
                details.Add(user);
            }
            JavaScriptSerializer oSerializer = new JavaScriptSerializer();
            return oSerializer.Serialize(details);

        }
        public int DeleteRow(int EventId)
        {
            object objfocus = obuser.DeleteEvent(EventId);
            JavaScriptSerializer oSerializer = new JavaScriptSerializer();
            return Convert.ToInt32(oSerializer.Serialize(objfocus));
        }
        public int insertEvent(int EventId)
        {
            object objfocus = obuser.insertEvent(EventId);
            JavaScriptSerializer oSerializer = new JavaScriptSerializer();
            return Convert.ToInt32(oSerializer.Serialize(objfocus));
        }
        public int DeletePortalClient(int CID, int EID)
        {
            object objfocus = obuser.DeletePortalClient(CID, EID);
            JavaScriptSerializer oSerializer = new JavaScriptSerializer();
            return Convert.ToInt32(oSerializer.Serialize(objfocus));
        }
        public int UpdatePortalClient(int CID, int EID)
        {
            object objfocus = obuser.UpdatePortalClient(CID, EID);
            JavaScriptSerializer oSerializer = new JavaScriptSerializer();
            return Convert.ToInt32(oSerializer.Serialize(objfocus));
        }
        public int UpdateEventActDeact(int EventId,int Userid)
        {
            object objfocus = obuser.UpdateEventActDeact(EventId,Userid);
            JavaScriptSerializer oSerializer = new JavaScriptSerializer();
            return Convert.ToInt32(oSerializer.Serialize(objfocus));
        }
        public string GetClintPortal(int EventId,int CID)
        {


           
            DataTable dt = new DataTable();
           // DataTable dt1 = new DataTable();
            DataSet ds = obuser.GetClintPortal(CID,EventId);
            dt = ds.Tables[0];
           // dt1 = ds.Tables[1];
            int ab = dt.Rows.Count;
            foreach (DataRow dtrow in dt.Rows)
            {
                ManageEventForGried user = new ManageEventForGried();
                user.EventID = Convert.ToInt32(dtrow["ClientID"].ToString());
                user.EventName = dtrow["BusinessName"].ToString();
                user.deleted = dtrow["Deleted"].ToString();
                if (dtrow["Portal"].ToString() != "")
                {
                    user.Portals1 = dtrow["Portal"].ToString();
                }
                else { user.Portals1 = "N/A"; }
              
               

               
                details.Add(user);
            }
            //foreach (DataRow dtrow in dt1.Rows)
            //{
            //    ManageEventForGried user = new ManageEventForGried();

            //    user.Portals = Convert.ToInt32(dtrow["ClientID"].ToString());


            //    details.Add(user);
            //}
            //List<ManageEventForGried> objfocus = objmanageproducts.ShowAllProducts();
            JavaScriptSerializer oSerializer = new JavaScriptSerializer();


            return Convert.ToString(oSerializer.Serialize(details));

        }
        public string GetAllProducts(int DdlProd,int DdlActive)
        {
           
           
            
            DataTable dt = new DataTable();
            DataSet ds = obuser.getallEvent(DdlProd,DdlActive);
            dt = ds.Tables[0];
            int ab = dt.Rows.Count;
            foreach (DataRow dtrow in dt.Rows)
            {
                ManageEventForGried user = new ManageEventForGried();
                user.EventID = Convert.ToInt32(dtrow["EventID"].ToString());
                user.EventName = dtrow["EventName"].ToString();
                user.Product = dtrow["ProductName"].ToString();
                user.Active = Convert.ToBoolean(dtrow["Active"]);
               
               
                if (dtrow["assignedportal"].ToString() != "")
                {
                    user.Portals1 = dtrow["assignedportal"].ToString();
                }
                else { user.Portals1 ="N/A"; }
                if (dtrow["TotalPortal"].ToString() != "")
                {
                    user.TotalClient = dtrow["TotalPortal"].ToString();
                }
                else { user.TotalClient = "N/A"; }
               
                details.Add(user);
            }
            //List<ManageEventForGried> objfocus = objmanageproducts.ShowAllProducts();
         JavaScriptSerializer oSerializer = new JavaScriptSerializer();


         return Convert.ToString(oSerializer.Serialize(details));
           
        }
        public class ManageEventForGried
        {

            public int EventID
            {
                get;
                set;
            }
           
            public string EventName{ get;set;}
            public string Product
            { get; set; }
            public string Status { get; set; }
            public Boolean Active { get; set; }
            public int Portals { get; set; }
            public string Portals1 { get; set; }
            public string name { get; set; }
            public string TotalClient { get; set; }
            public string deleted { get; set; }
        }
        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }



.CSS

#mainContent
{   background: none repeat scroll 0% 0% rgb(255, 255, 255);
    }
 body
{
    margin: 0;
    padding: 0;
   /* width: 100%;*/
    font-family: Arial;
}
h1, h2, h3, h4, h5, h6
{
    margin: 0;
    padding: 0;
}
ul
{
    list-style: none outside none;
    margin: 0;
    padding: 0;
}
li
{
    list-style: none outside none;
    margin: 0;
    padding: 0;
}
.text
{
font-size:16px;
color:#000000;
text-decoration:none;
font-family:Arial, Helvetica, sans-serif;
}


#education_entry1
{
    margin: 23px auto 0;
   
    min-height:638px;
    position: relative;
    border: 1px solid;
    width: 1000px;
}
.dnnLabel
{
    width:auto !important;}
    .mGrid { width: 100%; background-color: #fff; margin: 5px 0 10px 0; border: solid 1px #424242; border-collapse: collapse; }
.mGrid td { border: 1px solid #C1C1C1; color: #717171; height: 30px; line-height: 30px; padding: 0 5px; font-size: 12px; }
.mGrid th { background: url("images/grd_head.png") repeat-x scroll center top #424242; border-left: 1px solid #424242; color: #FFFFFF; font-size: 12px; height: 30px; line-height: 30px; padding: 0 5px; text-align: center; }
.mGrid th a{   color: #FFFFFF !important; font-size: 12px; height: 30px; line-height: 30px; padding: 0 5px; text-align: center; }
.mGrid th a:hover{   color:#fff; font-size: 12px; height: 30px; line-height: 30px; padding: 0 5px; text-align: center; }
.mGrid .alt { background: #fcfcfc url(images/grd_alt.png) repeat-x top; }
.mGrid .pgr { background: #424242 url(images/grd_pgr.png) repeat-x top; }
.mGrid .pgr table { margin: 5px 0; }
.mGrid .pgr td { border-width: 0; padding: 0 6px; border-left: solid 1px #666; font-weight: bold; color: #fff; line-height: 12px; }
.mGrid .pgr a { color: #666; text-decoration: none; }
.mGrid .pgr a:hover { color: #FFFFFF; text-decoration: none; }
span.dnnInputFileWrapper > input[type="file"]
{
    transform: none ! important; }






#MngCaption.dropdown
{
    width:497px !important;
    background-color: #EDEDED !important;
    border-bottom-left-radius: 4px !important;
    border-bottom-right-radius: 4px !important;
    border-top-left-radius: 4px !important;
    background: url("images/select.png") repeat-x left top !important;
   
  
   
    width: 180px !important;
   
    height: 28px !important;
}

.CFC_NormalTextBox
{
    font-size: 12px;
    font-weight: normal;
    font-family: Arial, Helvetica, sans-serif;
    color: #333333 !important;
    border: 1px solid #666666;
    padding: 7px !important;
    margin-bottom: 4px !important;
    margin-left: 3px !important;
}
.buttonsave
    {
        background: url("images/grd_head.png") repeat-x scroll center top #424242 !important;
        border: 0 none !important;
        border-radius: 4px 4px 4px 4px;
        color: #FFFFFF;
        height: 27px;
      
        cursor: pointer;
        margin-left:5px;
    }
   
   .PDf_tab {
    float: right;
    margin-right: 45px;
    padding-top: 7px;
    position: absolute;
    right: 0;
    z-index: 98;
}
   
  .PDf_tab .linkbtn{ background: url("./images/pdf.png") no-repeat scroll center center transparent;
    height: 32px;
    width: 32px;
     padding-top: 15px;
}
  .PDf_tab .linkbtn1{ background: url("./images/CSV.png") no-repeat scroll center center transparent;
    height: 32px;
    width: 32px;
    padding-top: 15px;
}

#MngCaption
{
   
     border: 1px solid silver;
    border-radius: 4px 4px 4px 4px;
    margin-bottom: 10px;
    padding-left: 11px;
    padding-top: 17px;
     padding-right: 11px;
    }
    #MngCaption1
{
   
     border: 1px solid silver;
    border-radius: 4px 4px 4px 4px;
    margin-bottom: 10px;
    padding-left: 11px;
    padding-top: 17px;
    }
   
    #fldgrid
    {
        border: 1px solid silver;
    border-radius: 4px 4px 4px 4px;
    padding-bottom: 17px;
    padding-left: 0px;
    padding-top: 14px;
    position: relative;
        }
       
       
      
#Tabsearch {
    margin-top: 18px;
    position: absolute;
    right: 235px;
    z-index: 1;
}
 .CFC_NormalTextBox1

{
    font-size: 12px;
    font-weight: normal;
    font-family: Arial, Helvetica, sans-serif;
    color: #333333 !important;
    border: 1px solid #666666;
    padding: 7px !important;
    margin-bottom: 4px !important;
    margin-left: -9px  !important;
    }
    .buttonsave1
    {
        background: url("images/grd_head.png") repeat-x scroll center top #424242 !important;
        border: 0 none !important;
        border-radius: 4px 4px 4px 4px;
        color: #FFFFFF;
        height: 27px;
      
        cursor: pointer;
        margin-left:5px;
        padding:5px;
    }
    #Edu1 table td{width:50%;}