protected void Page_Load(object sender, EventArgs e) { if (Session["Comid"] == null) { Response.Redirect("~/Login.aspx"); } PageConn pgcon = new PageConn(); con = pgcon.dynconn; pagetitleclass pg = new pagetitleclass(); string strData = Request.Url.ToString(); char[] separator = new char[] { '/' }; compid = Session["comid"].ToString(); string[] strSplitArr = strData.Split(separator); int i = Convert.ToInt32(strSplitArr.Length); string page = strSplitArr[i - 1].ToString(); Page.Title = pg.getPageTitle(page); if (!IsPostBack) { Pagecontrol.dypcontrol(Page, page); ViewState["sortOrder"] = ""; lblCompany.Text = Session["Cname"].ToString(); rdlist1_SelectedIndexChanged(sender, e); rdipright_SelectedIndexChanged(sender, e); DataTable dr = new DataTable(); dr = ClsIp.SelctIpGridfill(ddlfilterbus.SelectedValue, 1, ddlfilteruser.SelectedValue); if (dr.Rows.Count == 0) { dr = ClsIp.SelctIpGridfill("0", 0, "0"); } if (dr.Rows.Count > 0) { rdlist1.SelectedIndex = 0; rdipright.Items[0].Text = "List of IP Addresses Allowed for Any Users"; rdipright.Items[1].Text = "List of IP Addresses Allowed for Specific Users"; rdipright.SelectedIndex = 0; rdlist1_SelectedIndexChanged(sender, e); rdipright_SelectedIndexChanged(sender, e); } else { rdlist1_SelectedIndexChanged(sender, e); } FillGridView1(); } if (IsPostBack) { dynip = HttpContext.Current.Request.UserHostName; } }
protected void FillGridView1() { if (rdipright.SelectedIndex == 0) { alluseripcheck(); } else { specificuseripcheck(); } DataTable dr = new DataTable(); if (rdipright.SelectedIndex == 1) { dr = ClsIp.SelctIpGridfill(ddlfilterbus.SelectedValue, 1, ddlfilteruser.SelectedValue); Label5.Visible = true; grduser.Columns[0].Visible = true; grduser.Columns[1].Visible = true; grduser.Columns[2].Visible = true; } else if (rdipright.SelectedIndex == 0) { dr = ClsIp.SelctIpGridfill("0", 0, "0"); Label5.Visible = false; grduser.Columns[0].Visible = false; grduser.Columns[1].Visible = false; grduser.Columns[2].Visible = false; } grduser.DataSource = dr; if (dr.Rows.Count == 0) { btnadtolist.Visible = true; // lblalready.Visible = false; // pnlcurrentip.Visible = false; } p = 0; for (int i = 0; i < dr.Rows.Count; i++) { if (p == 0) { if (dr.Rows[i]["IpAddress"].ToString() == dynip) { btnadtolist.Visible = false; //lblalready.Visible = true; // pnlcurrentip.Visible = true; p = 1; } else { btnadtolist.Visible = true; // lblalready.Visible = false; // pnlcurrentip.Visible = false; } } } DataView myDataView = new DataView(); myDataView = dr.DefaultView; if (hdnsortExp.Value != string.Empty) { myDataView.Sort = string.Format("{0} {1}", hdnsortExp.Value, hdnsortDir.Value); } grduser.DataBind(); //if (grduser.Rows.Count > 0) //{ // pnlusergrid.Visible = true; // pnlms.Visible = false; //} //else //{ // pnlusergrid.Visible = false; // pnlms.Visible = true; //} }