Click here to Skip to main content
15,893,588 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: How to create a browse button to get a folder path Pin
Christian Graus3-Jan-08 17:30
protectorChristian Graus3-Jan-08 17:30 
GeneralRe: How to create a browse button to get a folder path [modified] Pin
bircut3-Jan-08 17:37
bircut3-Jan-08 17:37 
GeneralRe: How to create a browse button to get a folder path Pin
Christian Graus3-Jan-08 17:54
protectorChristian Graus3-Jan-08 17:54 
GeneralRe: How to create a browse button to get a folder path [modified] Pin
bircut3-Jan-08 18:51
bircut3-Jan-08 18:51 
QuestionHow to get Client Confirmation Pin
ram19743-Jan-08 14:19
ram19743-Jan-08 14:19 
AnswerRe: How to get Client Confirmation Pin
Christian Graus3-Jan-08 16:49
protectorChristian Graus3-Jan-08 16:49 
GeneralRe: How to get Client Confirmation Pin
ram19743-Jan-08 18:14
ram19743-Jan-08 18:14 
GeneralCheckBox List Does not show previous page checked Items Pin
ctrlnick3-Jan-08 12:27
ctrlnick3-Jan-08 12:27 
Hi ,

I am facing a typical problem where the same piece of code works at one place and does not at some other place.
The problem is that the check box list does not show me the previous page checked items when I return to the previous page after doing some selections in the next page...

I have used this in the code "$$$ The Problem Occurs Here $$$ " to denote where the problem occurs

The following is the code.

private void RememberOldValues()
{
ArrayList CheckedIndex = new ArrayList();
int index = -1;
for (int i = 0; i <GridView_TestCase.Rows.Count;i++ )
{
GridViewRow row = GridView_TestCase.Rows[i];
index = (GridView_TestCase.PageIndex*GridView_TestCase.PageSize)+i;
bool isChecked = ((CheckBox)row.FindControl("chkSelect")).Checked;

if (Session["CHECKED_ITEMS"] != null)
CheckedIndex = (ArrayList)Session["CHECKED_ITEMS"];
if (isChecked)
{
if(!CheckedIndex.Contains(index))
CheckedIndex.Add(index);
}
else
CheckedIndex.Remove(index);
}
if (CheckedIndex != null && CheckedIndex.Count > 0)
Session["CHECKED_ITEMS"] = CheckedIndex;
}


//Method to repopulate checked index in GridView_TestCase
private void RePopulateValues()
{
ArrayList CheckedIndex = (ArrayList)Session["CHECKED_ITEMS"];
int index = -1;
if (CheckedIndex != null && CheckedIndex.Count > 0)
{
for (int i = 0; i < GridView_TestCase.Rows.Count; i++)
{
GridViewRow row = GridView_TestCase.Rows[i];
index = (GridView_TestCase.PageIndex * GridView_TestCase.PageSize) + i;
//Use If..Else here when the Second Grid View is ready
if (CheckedIndex.Contains(index))
{
CheckBox CheckItem = ((CheckBox)row.FindControl("chkSelect"));
CheckItem.Checked = true;
}
}
}
}

public void gv_MetaDisplay_PageIndexChanging(Object sender, GridViewPageEventArgs e)
{
RememberOldValues_MetaData();
gv_MetaDisplay.PageIndex = e.NewPageIndex;
RePopulateValues_MetaData();
}

private void RememberOldValues_MetaData()
{
ArrayList CheckedIndex = new ArrayList();
ArrayList TestSaved = new ArrayList();
int index = -1;
for (int i = 0; i < gv_MetaDisplay.Rows.Count; i++)
{
GridViewRow row = gv_MetaDisplay.Rows[i];
index = (gv_MetaDisplay.PageIndex * gv_MetaDisplay.PageSize) + i;
bool isChecked = ((CheckBox)row.FindControl("chkDataSave")).Checked;


if (Session["CHECKED_SAVEITEMS"] != null)
{
CheckedIndex = (ArrayList)Session["CHECKED_SAVEITEMS"];
TestSaved = (ArrayList)Session["CHECKED_TESTNAMES"];
}
if (isChecked)
{
if (!CheckedIndex.Contains(index))
{
{
CheckedIndex.Add(index);
TestSaved.Add(row.Cells[1].Text);
}
}
}
else
{
CheckedIndex.Remove(index);
TestSaved.Remove(row.Cells[2].Text);
}
if (CheckedIndex != null && CheckedIndex.Count > 0)
{
Session["CHECKED_SAVEITEMS"] = CheckedIndex;
Session["CHECKED_TESTNAMES"] = TestSaved;
}
}
}

private void RePopulateValues_MetaData()
{
ArrayList CheckedIndex = (ArrayList)Session["CHECKED_SAVEITEMS"];
int index = -1;
if (CheckedIndex != null && CheckedIndex.Count > 0)
{
for (int i = 0; i < gv_MetaDisplay.Rows.Count; i++)
{
GridViewRow row = gv_MetaDisplay.Rows[i];
index = (gv_MetaDisplay.PageIndex * gv_MetaDisplay.PageSize) + i;
//Use If..Else here when the Second Grid View is ready

//$$$ The Problem Occurs Here $$$

if (CheckedIndex.Contains(index))
{
CheckBox CheckItem = ((CheckBox)row.FindControl("chkDataSave"));
CheckItem.Checked = true;
// CheckItem.Visible = true;
//lbl_test.Text = CheckItem.Text;
// Response.Write(CheckItem.Text);
}
}
}
}
}






please help me.//

Thanks ,
Nickle

Happy Programming!

Regards,
Nikhil Pagidala

GeneralRe: CheckBox List Does not show previous page checked Items Pin
Christian Graus3-Jan-08 13:16
protectorChristian Graus3-Jan-08 13:16 
GeneralRe: CheckBox List Does not show previous page checked Items Pin
ctrlnick3-Jan-08 13:56
ctrlnick3-Jan-08 13:56 
GeneralRe: CheckBox List Does not show previous page checked Items Pin
Christian Graus3-Jan-08 14:23
protectorChristian Graus3-Jan-08 14:23 
GeneralRe: CheckBox List Does not show previous page checked Items Pin
ctrlnick4-Jan-08 6:19
ctrlnick4-Jan-08 6:19 
GeneralAdding UserControl to Page Pin
Stevo Z3-Jan-08 11:49
Stevo Z3-Jan-08 11:49 
GeneralRe: Adding UserControl to Page Pin
Christian Graus3-Jan-08 13:18
protectorChristian Graus3-Jan-08 13:18 
GeneralRe: Adding UserControl to Page Pin
Stevo Z3-Jan-08 21:42
Stevo Z3-Jan-08 21:42 
GeneralRe: Adding UserControl to Page Pin
Stevo Z4-Jan-08 10:23
Stevo Z4-Jan-08 10:23 
GeneralRe: Adding UserControl to Page Pin
Urs Enzler3-Jan-08 14:09
Urs Enzler3-Jan-08 14:09 
GeneralRe: Adding UserControl to Page Pin
Stevo Z3-Jan-08 21:42
Stevo Z3-Jan-08 21:42 
GeneralRe: Adding UserControl to Page Pin
Stevo Z4-Jan-08 10:21
Stevo Z4-Jan-08 10:21 
GeneralRe: Adding UserControl to Page Pin
ChrisKo4-Jan-08 11:37
ChrisKo4-Jan-08 11:37 
GeneralRe: Adding UserControl to Page Pin
Stevo Z5-Jan-08 22:48
Stevo Z5-Jan-08 22:48 
GeneralXML Bulk Insert Question Pin
archangel7173-Jan-08 6:25
archangel7173-Jan-08 6:25 
QuestionRandom Form Pin
Mr. Wonderful3-Jan-08 6:13
Mr. Wonderful3-Jan-08 6:13 
GeneralRe: Random Form Pin
Christian Graus3-Jan-08 10:38
protectorChristian Graus3-Jan-08 10:38 
GeneralDisable radio button Pin
kjosh3-Jan-08 5:49
kjosh3-Jan-08 5:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.