Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
20
Datagrid now binding on button click
posted

hi,

i have webDataGrid with checkbox.

my datagrid is populating from Search Criteria.

i can easily generate the grid. but when i check few rows in grid and trying to get those data in another search i am getting Grid.Rows.Count as -1.

here is my code:

 

for Search Buttoon to get Grid():

if

 

 

(txtSearch.Text != "" && txtSearch.Text != null)

 

 

{false;

 

 

gvPolicy.Visible = 

true;

 

 

btnClaims.Visible = 

true;

 

 

btnRunReport.Visible = 

true;

 

 

 

SecurityUsers currentUser = ((Global)HttpContext.Current.ApplicationInstance).CurrentUser;

 

lblComment.Visible = 

 

 

 

 

 

 

if (currentUser != null)  

 

{

 

List<string> profitCenterDesc = new List<string>();

 

 

SecurityUserProfitCenterService secProfitService = new SecurityUserProfitCenterService();

 

 

 

TList<SecurityUserProfitCenter> userProfitCntrs = secProfitService.GetBySecurityUserKey(currentUser.SecurityUserKey);

 

 

 

if (userProfitCntrs != null && userProfitCntrs.Count > 0)  

 

 

 

 

 

{

 

CdtProfitCenterService profitService = new CdtProfitCenterService();

 

 

foreach (SecurityUserProfitCenter userProfitCntr in userProfitCntrs)   

 

 {

CdtProfitCenter profitCntr = profitService.GetByProfitCenterCode(userProfitCntr.ProfitCenterCode);

 

profitCenterDesc.Add(profitCntr.ProfitCenterDesc);

}

if (profitCenterDesc.Count > 0)

{

ProfitCenterDescs = profitCenterDesc;

}

else

null;

{ ProfitCenterDescs = 

}

}

//gvPolicy.EnsureTemplates(); 

MfxPolicyService policyService = new MfxPolicyService();  

DataSet getPolicies = new DataSet();

getPolicies = policyService.GetPolicyGrid(dpSearch.SelectedValue.ToString(), txtSearch.Value.ToString(), chkAllPolicies.Checked);

gvPolicy.DataSource = getPolicies;

//gvPolicy.DataBind(); 

//gvPolicy.DataSourceID = "PolicyDataSource";  

GridRecord row = new GridRecord();  

CheckBox chkbox = new CheckBox();  

for (int i = 0; i < gvPolicy.Rows.Count; i++)

{ 

CheckBox chk = new CheckBox(); true;  

chk = FindCheckBox(gvPolicy, i);

chk.Enabled = 

 

}

for (int i = 0; i < gvPolicy.Rows.Count; i++)  

{

row = gvPolicy.Rows[i];

chkbox = FindCheckBox(gvPolicy, i);

String profitCenter = ((DataRowView)row.DataItem).Row["ProfitCenter"].ToString();  

//Label lblProfitCenter = (Label)e.Row.FindControl("lblProfitCenter"); 

 

if (ProfitCenterDescs != null && ProfitCenterDescs.Contains(profitCenter)) false; 

{

chkbox.Enabled = 

}  now when i select few checkboxes and try to get data the Grid.Rows.Count is -1.

}

 

code to get checked data: 

 

List 

 

<decimal> policyRootIds = new List<decimal>();

 

for (int  i = 0; i < gvPolicy.Rows.Count; i++) // is giving -1. GridRecord row = gvPolicy.Rows[i];  

 

 

{

 

CheckBox chkbox = FindCheckBox(gvPolicy, i);

Infragistics.Web.UI.Framework.Data.DataRecord dr = new Infragistics.Web.UI.Framework.Data.DataRecord(gvPolicy);  

if (chkbox.Checked)  

{

decimal rootId = (decimal)(((DataRowView)row.DataItem).Row["RootId"]);  

policyRootIds.Add(rootId);

}

}

if (policyRootIds.Count > 0) "PolicyRootIds"] = policyRootIds;  

{

Session[

 

}

else

"PolicyRootIds"] = null;

{

Session[

 

 please let me know if anyone knows about this.

Parents
No Data
Reply Children
No Data