hold checkbox values

Answers were Sorted based on User's Feedback



hold checkbox values..

Answer / sona

this one fr retrieving

private void CheckChkBoxStatusRetrieve()
{
ArrayList objChkBoxRetrieve=new ArrayList();
if (Cache[(Session["Userid"]
+ "BankReconChkBoxID")] != null)
{
objChkBoxRetrieve=(ArrayList)Cache[(Session
["Userid"] + "BankReconChkBoxID")];
for (int j = 0; j <
objChkBoxRetrieve.Count; j++)
{
for (int i = 0; i < CurPageCnt; i++)
{
if (objChkBoxRetrieve[j].ToString()
== ((Label)lstBankReconcilation.Items[i].FindControl
("lblVoucherId")).Text)//lblVoucherNo
{
((CheckBox)
lstBankReconcilation.Items[i].FindControl
("chkReconcile")).Checked = true;
((TextBox)
lstBankReconcilation.Items[i].FindControl
("txtReconcileDate")).Text = DateTime.Now.ToString
("dd/MM/yyyy");
}
}
}
}
}

Is This Answer Correct ?    3 Yes 0 No

hold checkbox values..

Answer / sona

1]
http://blog.evonet.com.au/post/2008/08/Maintaining-Checkbox-State-in-a-Listview.aspx

2]
http://demo.evonet.com.au/MaintainingListviewCheckboxState.aspx

3]
http://www.codeproject.com/KB/webforms/States_of_CheckBoxes.aspx

4] http://forums.asp.net/t/1282544.aspx

5]
http://www.ilearnttoday.com/index.php/c-aspnet-gridview-how-to-keep-modified-data-of-template-fields-when-paging-is-enabled/comment-page-1

Is This Answer Correct ?    2 Yes 0 No

hold checkbox values..

Answer / sona

private void CheckChkBoxStatusHold()
{
ArrayList objChkBoxID = new ArrayList();
if (Cache[(Session["Userid"]
+ "BankReconChkBoxID")] != null)
{
objChkBoxID=(ArrayList)Cache[(Session
["Userid"] + "BankReconChkBoxID")];
}
for (int i = 0; i < CurPageCnt; i++)
{
if (intCheckSave == 1)
{
if (((CheckBox)
lstBankReconcilation.Items[i].FindControl
("chkReconcile")).Checked == true)
{
objChkBoxID.Add(((Label)
lstBankReconcilation.Items[i].FindControl
("lblVoucherId")).Text);
DateTime dtReconDate =
Convert.ToDateTime((((TextBox)lstBankReconcilation.Items
[i].FindControl("txtReconcileDate")).Text), new CultureInfo
("hi-IN"));
objChkBoxID.Add(dtReconDate.ToString
("dd-MMM-yyyy"));

}
}
else if (intCheckSave == 0)
{
if (((CheckBox)
lstBankReconcilation.Items[i].FindControl
("chkReconcile")).Checked == false)
{
objChkBoxID.Add(((Label)
lstBankReconcilation.Items[i].FindControl
("lblVoucherId")).Text);
DateTime dtReconDate =
Convert.ToDateTime((((TextBox)lstBankReconcilation.Items
[i].FindControl("txtReconcileDate")).Text), new CultureInfo
("hi-IN"));
objChkBoxID.Add(dtReconDate.ToString
("dd-MMM-yyyy"));
}
}
}
Cache.Remove((Session["Userid"]
+ "BankReconChkBoxID"));
Cache[(Session["Userid"]
+ "BankReconChkBoxID")] = objChkBoxID;
}

Is This Answer Correct ?    1 Yes 1 No

hold checkbox values..

Answer / kris

private List<int> IDs
{
get
{
if (this.ViewState["IDs"] == null)
{
this.ViewState["IDs"] = new List<int>();
}
return (List<int>)this.ViewState["IDs"];
}
}


protected void AddRowstoIDList()
{
int checkAction = 0;

foreach (ListViewDataItem lvi in lvUsersinGroup.Items)
{
CheckBox chkSelect =
(CheckBox)lvi.FindControl("chkSelect");
if ((((chkSelect) != null)))
{
int ID =
Convert.ToInt32(lvUsersinGroup.DataKeys[lvi.DisplayIndex].Value);


if ((chkSelect.Checked &&
!this.IDs.Contains(ID)))
{
this.IDs.Add(ID);
checkAction += 1;
}
else if ((!chkSelect.Checked &&
this.IDs.Contains(ID)))
{
this.IDs.Remove(ID);
}
}
}


}

Is This Answer Correct ?    0 Yes 1 No

Post New Answer

More ASP.NET Code Interview Questions

how to upload an excel in c# ASP.Net?

3 Answers  


Code for Communicating over Sockets?

0 Answers  


How to use Client-side Script to Focus Controls in ASP.NET?

0 Answers  


Give coding for Exception Handling Techniques in ASP.NET?

3 Answers   Microsoft,


How we implement the paypal in my website and how we make a payment through Credit Card.

2 Answers  






how to design a ListView control?

1 Answers  


How to send e-mail from an ASP.NET application?

16 Answers   DataPoint, Infosys, Persistent, Radar, TCS, Wipro,


How to get Dynamically Linked Comboboxes Set?

0 Answers   HCL,


How to add checkbox to datagrid?

5 Answers  


HOw to Build a Nested GridView Control with ASP.NET?

2 Answers  


how the value of label is printed through a button in asp.net web application

3 Answers  


How to Bind Nested XML to a Repeater Control with Container.DataItem?

0 Answers  


Categories
  • ASP.NET Code Interview Questions ASP.NET Code (46)
  • VB.NET Code Interview Questions VB.NET Code (9)
  • C Sharp Code Interview Questions C Sharp Code (51)
  • ADO.NET Code Interview Questions ADO.NET Code (8)