Hi team,
i tried with your solution but it does't work.
The Error i got is below:-
[Server Error in '/Dinesh_Export/Admin' Application.
Operation is not valid due to the current state of the object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: Operation is not valid due to the current state of the object.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[InvalidOperationException: Operation is not valid due to the current state of the object.]
System.Web.HttpValueCollection.FillFromEncodedBytes(Byte[] bytes, Encoding encoding) +128
System.Web.HttpRequest.FillInFormCollection() +154
[HttpException (0x80004005): The URL-encoded form data is not valid.]
System.Web.HttpRequest.FillInFormCollection() +213
System.Web.HttpRequest.get_Form() +50
System.Web.TraceContext.InitRequest()
System.Web.TraceContext.VerifyStart()
System.Web.Util.Profiler.StartRequest(HttpContext context)
System.Web.HttpApplication.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData)
System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr) +486
Version Information: Microsoft .NET Framework Version:1.1.4322.2494; ASP.NET Version:1.1.4322.2494
My problem is on the application, we have 1071 check boxes for selecting the countries(Row wise) with the ICON TERMS(column wise). we have 7 icon terms and if we select complete column more than 5 and click on save then we are getting this error and if we select Complete column below 5 we are able to save them with out any error.
I am copying my code as well below :-
UserEdit.aspx.cs
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace XPortAdmin
{
/// <summary>
/// Summary description for UserEdit.
/// </summary>
public class UserEdit : System.Web.UI.Page
{
protected System.Web.UI.WebControls.TextBox txtUserId;
protected System.Web.UI.WebControls.TextBox txtUserName;
protected System.Web.UI.WebControls.TextBox txtUserEmail;
protected System.Web.UI.WebControls.CheckBox chkActive;
protected System.Web.UI.WebControls.Label lblHeader;
protected System.Web.UI.HtmlControls.HtmlGenericControl divCountries;
protected System.Web.UI.HtmlControls.HtmlInputHidden hidPB_Reason;
protected System.Web.UI.HtmlControls.HtmlInputHidden hidFocusOn;
protected System.Web.UI.WebControls.DataGrid dgRoles;
protected System.Web.UI.HtmlControls.HtmlGenericControl divRoles;
protected System.Web.UI.HtmlControls.HtmlInputHidden hid_ctI_set;
protected System.Web.UI.HtmlControls.HtmlInputHidden hid_ct3_set;
protected System.Web.UI.HtmlControls.HtmlInputHidden hid_ctE_set;
//BEGIN CR KFCQ00123223
protected System.Web.UI.HtmlControls.HtmlInputHidden hid_ctNAI_set;
protected System.Web.UI.HtmlControls.HtmlInputHidden hid_ctEUI_set;
protected System.Web.UI.HtmlControls.HtmlInputHidden hid_ctNAUS_set;
protected System.Web.UI.HtmlControls.HtmlInputHidden hid_ctLAI_set;
//END CR KFCQ00123223
protected System.Web.UI.WebControls.DataGrid dgCountries;
private void Page_Load(object sender, System.EventArgs e)
{
if (!IsPostBack)
{
dgCountries.DataSource = Common.getCountriesSortedByName();
dgCountries.DataBind();
dgRoles.DataSource = Common.dvRoles;
dgRoles.DataBind();
if (Request["uid"] != null)
{
showExistingUser(Request["uid"].ToString());
if (Request["copy"] != null)
{
txtUserId.BackColor = Color.White;
txtUserId.Text = "";
txtUserName.Text = "";
txtUserEmail.Text = "";
txtUserId.ReadOnly = false;
}
}
else
{
txtUserId.BackColor = Color.White;
hidFocusOn.Value = "txtUserId";
}
return;
}
if (hidPB_Reason.Value == "save")
verify_and_save();
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.dgCountries.SelectedIndexChanged += new System.EventHandler(this.dgCountries_SelectedIndexChanged);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void verify_and_save()
{
string countries = ComposeCountryString();
string role = "";
if (txtUserId.Text.Trim().Length == 0)
{
showAlert("User Logon ID must be entered", "txtUserId");
return;
}
if (txtUserName.Text.Trim().Length == 0)
{
showAlert("User Name must be entered", "txtUserName");
return;
}
if (txtUserEmail.Text.Trim().Length == 0)
{
showAlert("Email Address must be entered", "txtUserEmail");
return;
}
foreach (DataGridItem dgi in dgRoles.Items)
{
if (dgi.ItemType == ListItemType.Item || dgi.ItemType == ListItemType.AlternatingItem)
{
HtmlInputRadioButton rb = (HtmlInputRadioButton)(dgi.Cells[2].Controls[1]);
if (rb.Checked)
{
role = dgi.Cells[0].Text;
}
}
}
if (role.Length == 0)
{
showAlert("Select a Role", "");
return;
}
if (Request["uid"] != null)
if (Request["copy"] == null)
{
Common.ExecNonQuery(makeUpdateUser(countries, role));
}
else
{
Common.ExecNonQuery(makeInsertUser(countries, role));
}
else
Common.ExecNonQuery(makeInsertUser(countries, role));
string s = "window.opener.document.getElementById('hidRefreshUserPage').value = 'y';";
s += "window.close();";
s += "<script>" + s + "</script>";
Page.RegisterClientScriptBlock("gettingout",s);
Common.setDataReloadSignal();
}
private string ComposeCountryString()
{
string countries = String.Empty;
bool bAllCountries = true;
foreach (DataGridItem dgi in dgCountries.Items)
{
if (dgi.ItemType == ListItemType.Item || dgi.ItemType == ListItemType.AlternatingItem)
{
HtmlInputCheckBox rb_inter = (HtmlInputCheckBox)(dgi.Cells[2].Controls[1]);
HtmlInputCheckBox rb_3rd = (HtmlInputCheckBox)(dgi.Cells[3].Controls[1]);
HtmlInputCheckBox rb_kic = (HtmlInputCheckBox)(dgi.Cells[4].Controls[1]);
//BEGIN CR KFCQ00123223
HtmlInputCheckBox rb_nai = (HtmlInputCheckBox)(dgi.Cells[5].Controls[1]);
HtmlInputCheckBox rb_eui = (HtmlInputCheckBox)(dgi.Cells[6].Controls[1]);
HtmlInputCheckBox rb_naus = (HtmlInputCheckBox)(dgi.Cells[7].Controls[1]);
HtmlInputCheckBox rb_lai = (HtmlInputCheckBox)(dgi.Cells[8].Controls[1]);
//END CR KFCQ00123223
int k = 0;
if (rb_inter.Checked) k += 1;
if (rb_3rd.Checked) k += 2;
if (rb_kic.Checked) k += 4;
//BEGIN CR KFCQ00123223
if(rb_nai.Checked) k+=8;
if(rb_eui.Checked) k+=16;
if(rb_naus.Checked) k+=32;
if(rb_lai.Checked)k+=64;
//END CR KFCQ00123223
//BEGIN modified for CR KFCQ00123223
//if (k < 7)
if(k<127)
bAllCountries = false;
if (k > 0)
countries += dgi.Cells[0].Text + k.ToString() + "|";
//END CR KFCQ00123223
}
}
if (countries.Length > 0)
countries = countries.Substring(0,countries.Length - 1);
if (bAllCountries)
countries = "ALL";
return countries;
}
private void showAlert(string msg, string foc)
{
Page.RegisterStartupScript("inputerr","<script>alert('" + msg + "');</script>");
if (foc.Length > 0) hidFocusOn.Value=foc;
}
private string makeInsertUser(string countries, string role)
{
string sF = "Insert into " + Common.tblUser + " (";
string sV = " values (";
Common.addFieldForInsert(ref sF, ref sV, "NTUserId", txtUserId.Text.Trim(), true);
Common.addFieldForInsert(ref sF, ref sV, "UserName", txtUserName.Text.Trim(), true);
Common.addFieldForInsert(ref sF, ref sV, "UserCountries", countries, true);
Common.addFieldForInsert(ref sF, ref sV, "UserRole", role, true);
Common.addFieldForInsert(ref sF, ref sV, "UserActive", (chkActive.Checked)?"1":"0", false);
Common.addFieldForInsert(ref sF, ref sV, "UserEmail", txtUserEmail.Text.Trim(), true);
sF += ")";
sV += ")";
return sF + sV;
}
private string makeUpdateUser(string countries, string role)
{
string sSql = "";
sSql = "Update " + Common.tblUser + " set ";
sSql += Common.setFieldForUpdt("UserName", txtUserName.Text.Trim(), true);
sSql += ", " + Common.setFieldForUpdt("UserCountries",countries, true);
sSql += ", " + Common.setFieldForUpdt("UserRole",role, true);
sSql += ", " + Common.setFieldForUpdt("UserActive",(chkActive.Checked)?"1":"0", false);
sSql += ", " + Common.setFieldForUpdt("UserEmail",txtUserEmail.Text.Trim(), true);
sSql += " where NTUserId='" + txtUserId.Text.Trim() + "'";
return sSql;
}
private void showExistingUser(string uid)
{
txtUserId.ReadOnly = true;
DataTable dt = Common.getUser(uid);
txtUserId.Text = dt.Rows[0]["NTUserId"].ToString();
txtUserName.Text = dt.Rows[0]["UserName"].ToString();
txtUserEmail.Text = dt.Rows[0]["UserEmail"].ToString();
chkActive.Checked = dt.Rows[0]["UserActive"].ToString() != "0";
string sCountries = dt.Rows[0]["UserCountries"].ToString();
int cti_count = 0, ct3_count = 0, cte_count = 0;
//BEGIN CR KFCQ00123223
int ctnai_count=0,ctnaus_count=0,cteui_count=0,ctlai_count=0;
//END CR KFCQ00123223
foreach (DataGridItem dgi in dgCountries.Items)
{
if (dgi.ItemType == ListItemType.Item || dgi.ItemType == ListItemType.AlternatingItem)
{
// see if the country code for this grid row (2 chars) is amoung
// the pipe-separted list of country codes (+ digit appended) of this NT User:
int k = sCountries.IndexOf(dgi.Cells[0].Text);
if (sCountries == "ALL" || k != -1)
{
HtmlInputCheckBox rb_inter = (HtmlInputCheckBox)(dgi.Cells[2].Controls[1]);
HtmlInputCheckBox rb_3rd = (HtmlInputCheckBox)(dgi.Cells[3].Controls[1]);
HtmlInputCheckBox rb_kic = (HtmlInputCheckBox)(dgi.Cells[4].Controls[1]);
//BEGIN CR KFCQ00123223
HtmlInputCheckBox rb_nai = (HtmlInputCheckBox)(dgi.Cells[5].Controls[1]);
HtmlInputCheckBox rb_eui = (HtmlInputCheckBox)(dgi.Cells[6].Controls[1]);
HtmlInputCheckBox rb_naus = (HtmlInputCheckBox)(dgi.Cells[7].Controls[1]);
HtmlInputCheckBox rb_lai = (HtmlInputCheckBox)(dgi.Cells[8].Controls[1]);
//END CR KFCQ00123223
if (sCountries == "ALL")
{
rb_inter.Checked = true;
rb_3rd.Checked = true;
rb_kic.Checked = true;
//BEGIN CR KFCQ00123223
rb_eui.Checked = true;
rb_nai.Checked = true;
rb_naus.Checked = true;
rb_lai.Checked = true;
//END CR KFCQ00123223
}
else
{
k += 2; // step beyond 2-char code
if (k > sCountries.Length - 1 || sCountries.Substring(k,1) == "|")
{
// we are beyond the string or bumped into pipe (no digit after code - assume all cust types)
rb_inter.Checked = true;
rb_3rd.Checked = true;
rb_kic.Checked = true;
//BEGIN CR KFCQ00123223
rb_nai.Checked = true;
rb_eui.Checked = true;
rb_naus.Checked = true;
rb_lai.Checked = true;
//END CR KFCQ00123223
}
else
{
//BEGIN CR KFCQ00123223
//bug fix - (KFCQ00123223) email notification bug-C0000019015
string[] arCountries;
arCountries = sCountries.Split(new char[] {'|'});
for (int i=0; i < arCountries.Length; i=i+1)
{
if(arCountries[i].Substring(0,2)== dgi.Cells[0].Text)
{
int w = Convert.ToInt32(arCountries[i].Substring(2));
//int j=0;
//int charCount=1;
//int navCountry=k;
//while (j!=-1)
//{
// char c=sCountries.Substring(navCountry,1).ToCharArray()[0];
// if(c=='|' || navCountry==sCountries.Length-1)
// {
// j=-1;
// if (charCount==1)
// {
// charCount+=1;
// }
//
// }
// else
// {
// if(navCountry<sCountries.Length-1)
// {
// navCountry+=1;
// }
// else
// {
// navCountry=sCountries.Length-1;
// }
// charCount+=1;
// }
// }
// //sxl:qf; next 2 lines temp fix for 3-letter codes !
// char char3 = sCountries.Substring(k,1).ToCharArray()[0];
// if (char3 < '0' || char3 > '9') k++;
// // assume one digit only after country code:
// string s=sCountries.Substring(k,charCount-1);
// int w = Convert.ToInt32(sCountries.Substring(k,charCount-1));
if ((w & 0x01) > 0) rb_inter.Checked = true;
if ((w & 0x02) > 0) rb_3rd.Checked = true;
if ((w & 0x04) > 0) rb_kic.Checked = true;
if ((w & 0x08) > 0) rb_nai.Checked = true;
if ((w & 0x10) > 0) rb_eui.Checked = true;
if ((w & 0x20) > 0) rb_naus.Checked = true;
if ((w & 0x40) > 0) rb_lai.Checked = true;
//this below break is added to increase the effeciency of the code
//C0000019015
break;
}
}
//END CR KFCQ00123223
////// //sxl:qf; next 2 lines temp fix for 3-letter codes !
////// char char3 = sCountries.Substring(k,1).ToCharArray()[0];
////// if (char3 < '0' || char3 > '9') k++;
////// // assume one digit only after country code:
////// int w = Convert.ToInt32(sCountries.Substring(k,1));
////// if ((w & 0x01) > 0) rb_inter.Checked = true;
////// if ((w & 0x02) > 0) rb_3rd.Checked = true;
////// if ((w & 0x04) > 0) rb_kic.Checked = true;
//////
}
}
if (rb_inter.Checked) cti_count++;
if (rb_3rd.Checked) ct3_count++;
if (rb_kic.Checked) cte_count++;
//BEGIN CR KFCQ00123223
if (rb_nai.Checked) ctnai_count++;
if (rb_eui.Checked) cteui_count++;
if (rb_naus.Checked) ctnaus_count++;
if (rb_lai.Checked) ctlai_count++;
//END CR KFCQ00123223
}
}
}
if (dgCountries.Items.Count == cti_count) hid_ctI_set.Value = "y";
if (dgCountries.Items.Count == ct3_count) hid_ct3_set.Value = "y";
if (dgCountries.Items.Count == cte_count) hid_ctE_set.Value = "y";
//BEGIN CR KFCQ00123223
if (dgCountries.Items.Count == ctnai_count) hid_ctNAI_set.Value = "y";
if (dgCountries.Items.Count == cteui_count) hid_ctEUI_set.Value = "y";
if (dgCountries.Items.Count == ctnaus_count) hid_ctNAUS_set.Value = "y";
if (dgCountries.Items.Count == ctlai_count) hid_ctLAI_set.Value = "y";
//END CR KFCQ00123223
foreach (DataGridItem dgi in dgRoles.Items)
{
if (dgi.ItemType == ListItemType.Item || dgi.ItemType == ListItemType.AlternatingItem)
{
if (dt.Rows[0]["UserRole"].ToString().IndexOf(dgi.Cells[0].Text) != -1)
{
System.Web.UI.HtmlControls.HtmlInputRadioButton rb =
(System.Web.UI.HtmlControls.HtmlInputRadioButton)(dgi.Cells[2].Controls[1]);
rb.Checked = true;
}
}
}
}
private void dgCountries_SelectedIndexChanged(object sender, System.EventArgs e)
{
}
}
}
UserEdit.aspx
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace XPortAdmin
{
/// <summary>
/// Summary description for UserEdit.
/// </summary>
public class UserEdit : System.Web.UI.Page
{
protected System.Web.UI.WebControls.TextBox txtUserId;
protected System.Web.UI.WebControls.TextBox txtUserName;
protected System.Web.UI.WebControls.TextBox txtUserEmail;
protected System.Web.UI.WebControls.CheckBox chkActive;
protected System.Web.UI.WebControls.Label lblHeader;
protected System.Web.UI.HtmlControls.HtmlGenericControl divCountries;
protected System.Web.UI.HtmlControls.HtmlInputHidden hidPB_Reason;
protected System.Web.UI.HtmlControls.HtmlInputHidden hidFocusOn;
protected System.Web.UI.WebControls.DataGrid dgRoles;
protected System.Web.UI.HtmlControls.HtmlGenericControl divRoles;
protected System.Web.UI.HtmlControls.HtmlInputHidden hid_ctI_set;
protected System.Web.UI.HtmlControls.HtmlInputHidden hid_ct3_set;
protected System.Web.UI.HtmlControls.HtmlInputHidden hid_ctE_set;
//BEGIN CR KFCQ00123223
protected System.Web.UI.HtmlControls.HtmlInputHidden hid_ctNAI_set;
protected System.Web.UI.HtmlControls.HtmlInputHidden hid_ctEUI_set;
protected System.Web.UI.HtmlControls.HtmlInputHidden hid_ctNAUS_set;
protected System.Web.UI.HtmlControls.HtmlInputHidden hid_ctLAI_set;
//END CR KFCQ00123223
protected System.Web.UI.WebControls.DataGrid dgCountries;
private void Page_Load(object sender, System.EventArgs e)
{
if (!IsPostBack)
{
dgCountries.DataSource = Common.getCountriesSortedByName();
dgCountries.DataBind();
dgRoles.DataSource = Common.dvRoles;
dgRoles.DataBind();
if (Request["uid"] != null)
{
showExistingUser(Request["uid"].ToString());
if (Request["copy"] != null)
{
txtUserId.BackColor = Color.White;
txtUserId.Text = "";
txtUserName.Text = "";
txtUserEmail.Text = "";
txtUserId.ReadOnly = false;
}
}
else
{
txtUserId.BackColor = Color.White;
hidFocusOn.Value = "txtUserId";
}
return;
}
if (hidPB_Reason.Value == "save")
verify_and_save();
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.dgCountries.SelectedIndexChanged += new System.EventHandler(this.dgCountries_SelectedIndexChanged);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void verify_and_save()
{
string countries = ComposeCountryString();
string role = "";
if (txtUserId.Text.Trim().Length == 0)
{
showAlert("User Logon ID must be entered", "txtUserId");
return;
}
if (txtUserName.Text.Trim().Length == 0)
{
showAlert("User Name must be entered", "txtUserName");
return;
}
if (txtUserEmail.Text.Trim().Length == 0)
{
showAlert("Email Address must be entered", "txtUserEmail");
return;
}
foreach (DataGridItem dgi in dgRoles.Items)
{
if (dgi.ItemType == ListItemType.Item || dgi.ItemType == ListItemType.AlternatingItem)
{
HtmlInputRadioButton rb = (HtmlInputRadioButton)(dgi.Cells[2].Controls[1]);
if (rb.Checked)
{
role = dgi.Cells[0].Text;
}
}
}
if (role.Length == 0)
{
showAlert("Select a Role", "");
return;
}
if (Request["uid"] != null)
if (Request["copy"] == null)
{
Common.ExecNonQuery(makeUpdateUser(countries, role));
}
else
{
Common.ExecNonQuery(makeInsertUser(countries, role));
}
else
Common.ExecNonQuery(makeInsertUser(countries, role));
string s = "window.opener.document.getElementById('hidRefreshUserPage').value = 'y';";
s += "window.close();";
s += "<script>" + s + "</script>";
Page.RegisterClientScriptBlock("gettingout",s);
Common.setDataReloadSignal();
}
private string ComposeCountryString()
{
string countries = String.Empty;
bool bAllCountries = true;
foreach (DataGridItem dgi in dgCountries.Items)
{
if (dgi.ItemType == ListItemType.Item || dgi.ItemType == ListItemType.AlternatingItem)
{
HtmlInputCheckBox rb_inter = (HtmlInputCheckBox)(dgi.Cells[2].Controls[1]);
HtmlInputCheckBox rb_3rd = (HtmlInputCheckBox)(dgi.Cells[3].Controls[1]);
HtmlInputCheckBox rb_kic = (HtmlInputCheckBox)(dgi.Cells[4].Controls[1]);
//BEGIN CR KFCQ00123223
HtmlInputCheckBox rb_nai = (HtmlInputCheckBox)(dgi.Cells[5].Controls[1]);
HtmlInputCheckBox rb_eui = (HtmlInputCheckBox)(dgi.Cells[6].Controls[1]);
HtmlInputCheckBox rb_naus = (HtmlInputCheckBox)(dgi.Cells[7].Controls[1]);
HtmlInputCheckBox rb_lai = (HtmlInputCheckBox)(dgi.Cells[8].Controls[1]);
//END CR KFCQ00123223
int k = 0;
if (rb_inter.Checked) k += 1;
if (rb_3rd.Checked) k += 2;
if (rb_kic.Checked) k += 4;
//BEGIN CR KFCQ00123223
if(rb_nai.Checked) k+=8;
if(rb_eui.Checked) k+=16;
if(rb_naus.Checked) k+=32;
if(rb_lai.Checked)k+=64;
//END CR KFCQ00123223
//BEGIN modified for CR KFCQ00123223
//if (k < 7)
if(k<127)
bAllCountries = false;
if (k > 0)
countries += dgi.Cells[0].Text + k.ToString() + "|";
//END CR KFCQ00123223
}
}
if (countries.Length > 0)
countries = countries.Substring(0,countries.Length - 1);
if (bAllCountries)
countries = "ALL";
return countries;
}
private void showAlert(string msg, string foc)
{
Page.RegisterStartupScript("inputerr","<script>alert('" + msg + "');</script>");
if (foc.Length > 0) hidFocusOn.Value=foc;
}
private string makeInsertUser(string countries, string role)
{
string sF = "Insert into " + Common.tblUser + " (";
string sV = " values (";
Common.addFieldForInsert(ref sF, ref sV, "NTUserId", txtUserId.Text.Trim(), true);
Common.addFieldForInsert(ref sF, ref sV, "UserName", txtUserName.Text.Trim(), true);
Common.addFieldForInsert(ref sF, ref sV, "UserCountries", countries, true);
Common.addFieldForInsert(ref sF, ref sV, "UserRole", role, true);
Common.addFieldForInsert(ref sF, ref sV, "UserActive", (chkActive.Checked)?"1":"0", false);
Common.addFieldForInsert(ref sF, ref sV, "UserEmail", txtUserEmail.Text.Trim(), true);
sF += ")";
sV += ")";
return sF + sV;
}
private string makeUpdateUser(string countries, string role)
{
string sSql = "";
sSql = "Update " + Common.tblUser + " set ";
sSql += Common.setFieldForUpdt("UserName", txtUserName.Text.Trim(), true);
sSql += ", " + Common.setFieldForUpdt("UserCountries",countries, true);
sSql += ", " + Common.setFieldForUpdt("UserRole",role, true);
sSql += ", " + Common.setFieldForUpdt("UserActive",(chkActive.Checked)?"1":"0", false);
sSql += ", " + Common.setFieldForUpdt("UserEmail",txtUserEmail.Text.Trim(), true);
sSql += " where NTUserId='" + txtUserId.Text.Trim() + "'";
return sSql;
}
private void showExistingUser(string uid)
{
txtUserId.ReadOnly = true;
DataTable dt = Common.getUser(uid);
txtUserId.Text = dt.Rows[0]["NTUserId"].ToString();
txtUserName.Text = dt.Rows[0]["UserName"].ToString();
txtUserEmail.Text = dt.Rows[0]["UserEmail"].ToString();
chkActive.Checked = dt.Rows[0]["UserActive"].ToString() != "0";
string sCountries = dt.Rows[0]["UserCountries"].ToString();
int cti_count = 0, ct3_count = 0, cte_count = 0;
//BEGIN CR KFCQ00123223
int ctnai_count=0,ctnaus_count=0,cteui_count=0,ctlai_count=0;
//END CR KFCQ00123223
foreach (DataGridItem dgi in dgCountries.Items)
{
if (dgi.ItemType == ListItemType.Item || dgi.ItemType == ListItemType.AlternatingItem)
{
// see if the country code for this grid row (2 chars) is amoung
// the pipe-separted list of country codes (+ digit appended) of this NT User:
int k = sCountries.IndexOf(dgi.Cells[0].Text);
if (sCountries == "ALL" || k != -1)
{
HtmlInputCheckBox rb_inter = (HtmlInputCheckBox)(dgi.Cells[2].Controls[1]);
HtmlInputCheckBox rb_3rd = (HtmlInputCheckBox)(dgi.Cells[3].Controls[1]);
HtmlInputCheckBox rb_kic = (HtmlInputCheckBox)(dgi.Cells[4].Controls[1]);
//BEGIN CR KFCQ00123223
HtmlInputCheckBox rb_nai = (HtmlInputCheckBox)(dgi.Cells[5].Controls[1]);
HtmlInputCheckBox rb_eui = (HtmlInputCheckBox)(dgi.Cells[6].Controls[1]);
HtmlInputCheckBox rb_naus = (HtmlInputCheckBox)(dgi.Cells[7].Controls[1]);
HtmlInputCheckBox rb_lai = (HtmlInputCheckBox)(dgi.Cells[8].Controls[1]);
//END CR KFCQ00123223
if (sCountries == "ALL")
{
rb_inter.Checked = true;
rb_3rd.Checked = true;
rb_kic.Checked = true;
//BEGIN CR KFCQ00123223
rb_eui.Checked = true;
rb_nai.Checked = true;
rb_naus.Checked = true;
rb_lai.Checked = true;
//END CR KFCQ00123223
}
else
{
k += 2; // step beyond 2-char code
if (k > sCountries.Length - 1 || sCountries.Substring(k,1) == "|")
{
// we are beyond the string or bumped into pipe (no digit after code - assume all cust types)
rb_inter.Checked = true;
rb_3rd.Checked = true;
rb_kic.Checked = true;
//BEGIN CR KFCQ00123223
rb_nai.Checked = true;
rb_eui.Checked = true;
rb_naus.Checked = true;
rb_lai.Checked = true;
//END CR KFCQ00123223
}
else
{
//BEGIN CR KFCQ00123223
//bug fix - (KFCQ00123223) email notification bug-C0000019015
string[] arCountries;
arCountries = sCountries.Split(new char[] {'|'});
for (int i=0; i < arCountries.Length; i=i+1)
{
if(arCountries[i].Substring(0,2)== dgi.Cells[0].Text)
{
int w = Convert.ToInt32(arCountries[i].Substring(2));
//int j=0;
//int charCount=1;
//int navCountry=k;
//while (j!=-1)
//{
// char c=sCountries.Substring(navCountry,1).ToCharArray()[0];
// if(c=='|' || navCountry==sCountries.Length-1)
// {
// j=-1;
// if (charCount==1)
// {
// charCount+=1;
// }
//
// }
// else
// {
// if(navCountry<sCountries.Length-1)
// {
// navCountry+=1;
// }
// else
// {
// navCountry=sCountries.Length-1;
// }
// charCount+=1;
// }
// }
// //sxl:qf; next 2 lines temp fix for 3-letter codes !
// char char3 = sCountries.Substring(k,1).ToCharArray()[0];
// if (char3 < '0' || char3 > '9') k++;
// // assume one digit only after country code:
// string s=sCountries.Substring(k,charCount-1);
// int w = Convert.ToInt32(sCountries.Substring(k,charCount-1));
if ((w & 0x01) > 0) rb_inter.Checked = true;
if ((w & 0x02) > 0) rb_3rd.Checked = true;
if ((w & 0x04) > 0) rb_kic.Checked = true;
if ((w & 0x08) > 0) rb_nai.Checked = true;
if ((w & 0x10) > 0) rb_eui.Checked = true;
if ((w & 0x20) > 0) rb_naus.Checked = true;
if ((w & 0x40) > 0) rb_lai.Checked = true;
//this below break is added to increase the effeciency of the code
//C0000019015
break;
}
}
//END CR KFCQ00123223
////// //sxl:qf; next 2 lines temp fix for 3-letter codes !
////// char char3 = sCountries.Substring(k,1).ToCharArray()[0];
////// if (char3 < '0' || char3 > '9') k++;
////// // assume one digit only after country code:
////// int w = Convert.ToInt32(sCountries.Substring(k,1));
////// if ((w & 0x01) > 0) rb_inter.Checked = true;
////// if ((w & 0x02) > 0) rb_3rd.Checked = true;
////// if ((w & 0x04) > 0) rb_kic.Checked = true;
//////
}
}
if (rb_inter.Checked) cti_count++;
if (rb_3rd.Checked) ct3_count++;
if (rb_kic.Checked) cte_count++;
//BEGIN CR KFCQ00123223
if (rb_nai.Checked) ctnai_count++;
if (rb_eui.Checked) cteui_count++;
if (rb_naus.Checked) ctnaus_count++;
if (rb_lai.Checked) ctlai_count++;
//END CR KFCQ00123223
}
}
}
if (dgCountries.Items.Count == cti_count) hid_ctI_set.Value = "y";
if (dgCountries.Items.Count == ct3_count) hid_ct3_set.Value = "y";
if (dgCountries.Items.Count == cte_count) hid_ctE_set.Value = "y";
//BEGIN CR KFCQ00123223
if (dgCountries.Items.Count == ctnai_count) hid_ctNAI_set.Value = "y";
if (dgCountries.Items.Count == cteui_count) hid_ctEUI_set.Value = "y";
if (dgCountries.Items.Count == ctnaus_count) hid_ctNAUS_set.Value = "y";
if (dgCountries.Items.Count == ctlai_count) hid_ctLAI_set.Value = "y";
//END CR KFCQ00123223
foreach (DataGridItem dgi in dgRoles.Items)
{
if (dgi.ItemType == ListItemType.Item || dgi.ItemType == ListItemType.AlternatingItem)
{
if (dt.Rows[0]["UserRole"].ToString().IndexOf(dgi.Cells[0].Text) != -1)
{
System.Web.UI.HtmlControls.HtmlInputRadioButton rb =
(System.Web.UI.HtmlControls.HtmlInputRadioButton)(dgi.Cells[2].Controls[1]);
rb.Checked = true;
}
}
}
}
private void dgCountries_SelectedIndexChanged(object sender, System.EventArgs e)
{
}
}
}
Can anyone help me on this. i am struggling with this from last 4 days...
Regards,
Jack147