Click here to Skip to main content
15,892,161 members
Home / Discussions / ASP.NET
   

ASP.NET

 
QuestionJavaScript Shift + : Pin
dptalt22-Sep-09 2:36
dptalt22-Sep-09 2:36 
AnswerRe: JavaScript Shift + : Pin
Robert_Pan22-Sep-09 3:43
Robert_Pan22-Sep-09 3:43 
GeneralRe: JavaScript Shift + : Pin
dptalt22-Sep-09 3:54
dptalt22-Sep-09 3:54 
QuestionData from SQL & Header from XML??? Pin
KittyKit22-Sep-09 1:52
KittyKit22-Sep-09 1:52 
AnswerRe: Data from SQL & Header from XML??? Pin
Not Active22-Sep-09 3:02
mentorNot Active22-Sep-09 3:02 
QuestionGridView Pagination Problem Pin
JMAboliEnrich22-Sep-09 1:30
JMAboliEnrich22-Sep-09 1:30 
AnswerRe: GridView Pagination Problem Pin
keyur satyadev22-Sep-09 2:23
keyur satyadev22-Sep-09 2:23 
GeneralRe: GridView Pagination Problem Pin
JMAboliEnrich22-Sep-09 20:47
JMAboliEnrich22-Sep-09 20:47 
Thanks for your instant reply, Keyur Smile | :)

Sorry for not posting code ...

here is the situation.......

i hv Grid View Control consist of two labels and 10 check boxes...

<asp:GridView ID="GrdAccess" runat="server" AutoGenerateColumns="False"    DataKeyNames="OptionId"  Width="100%"  OnRowCommand="GrdAccess_RowCommand"   OnRowDataBound="GrdAccess_RowDataBound" AllowPaging="false"  ondatabound="GrdAccess_DataBound"         onpageindexchanging="GrdAccess_PageIndexChanging"
 >               <
Columns> <asp:TemplateField HeaderText="OptionId" Visible="false">
                <ItemTemplate>         <asp:Label ID="lblOptionId" runat="server" Text='<%# Bind("OptionId")%>'></asp:Label>     </ItemTemplate>                                                  
</asp:TemplateField>
<asp:TemplateField HeaderText="OptionName"
  ><ItemTemplate>                       <asp:Label ID="lblOption" runat="server" Text='<%# Bind("OptionName")%>'></asp:Label>   </ItemTemplate>                          </asp:TemplateField>
                                                 <asp:TemplateField HeaderText="Acronym" Visible="False"  > <ItemTemplate>
 <asp:Label ID="lblAcronym" runat="server" Text='<%# Bind("Acronym")%>'></asp:Label>      </ItemTemplate>                         </asp:TemplateField>
                                                <asp:TemplateField HeaderText="Create/Add">                      <ItemTemplate>
 <asp:CheckBox ID="ChkNew" runat="server" AutoPostBack="true" TextAlign="Left"    />                           <asp:HiddenField ID="HidChkNew" runat="server" Value="C" />                                                     </ItemTemplate>                              <HeaderStyle HorizontalAlign="Left" />                        <ItemStyle HorizontalAlign ="Center" VerticalAlign="Middle" />                                                 </asp:TemplateField>  <asp:TemplateField HeaderText="Edit">
 <ItemTemplate>                                <asp:CheckBox ID="ChkEdit" runat="server" AutoPostBack="true"  />
  <asp:HiddenField ID="HidChkEdit" runat="server" Value="E" />
 </ItemTemplate> 
 <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />                           </asp:TemplateField> 
                                                 <asp:TemplateField HeaderText="Delete">                          <ItemTemplate>
<asp:CheckBox ID="ChkDelete" runat="server" AutoPostBack="true" />
 <asp:HiddenField ID="HidChkDelete" runat="server" Value="D" />
 </ItemTemplate>             <ItemStyle HorizontalAlign="Center"  />                                           </asp:TemplateField> 
  <ItemTemplate>                                                       <asp:CheckBox ID="ChkAll" runat="server" AutoPostBack="true" />
</ItemTemplate> 
</asp:TemplateField>                  </Columns>
 <EmptyDataTemplate>
 No Data Found
</EmptyDataTemplate>
  </asp:GridView> 


On Save button click i am saving all selected access into database..

i am using function similar to this

protected void CmdSave_Click(object sender, EventArgs e)
{
string StrRoleAcccess = "";
string StrOption = "";
string StrChkAccess = "";
string StrFlag = "";
if (CBRoleName.SelectedItem.Text != "--Select--")
{
trErrMessage.Visible = false;
for (int RowCnt = 0; RowCnt < GrdAccess.Rows.Count; RowCnt++)
{
foreach (GridViewRow RowFile in GrdAccess.Rows)
{

for (int i = 2; i < RowFile.Cells.Count; i++)
{
//RowFile.Cells[2].Controls[1].ID
if (RowFile.Cells[i].Controls[1].GetType() == typeof(CheckBox))
{
CheckBox ObjCnt = new CheckBox();
ObjCnt = (CheckBox)RowFile.Cells[i].Controls[1];
if (ObjCnt.Checked)
{
StrFlag = "True";
// FrLoadChkCount++;
} } } }

if (StrFlag == "True")
{
foreach (GridViewRow RowFile in GrdAccess.Rows)
{
for (int i = 2; i < RowFile.Cells.Count - 1; i++)
{
//RowFile.Cells[2].Controls[1].ID
if (RowFile.Cells[i].Controls[1].GetType() == typeof(CheckBox))
{
CheckBox ObjCnt = new CheckBox();
ObjCnt = (CheckBox)RowFile.Cells[i].Controls[1];
if (ObjCnt.Checked)
{

{
Label LblFldOption = (Label)RowFile.Cells[i].FindControl("lblAcronym");
StrOption = LblFldOption.Text.ToString().Trim() + "_";
HiddenField HidCnt = (HiddenField)(RowFile.Cells[i].FindControl("Hid" + ObjCnt.ID));
StrChkAccess = HidCnt.Value;
StrRoleAcccess += "," + StrOption + StrChkAccess;
} } }}}
StrRoleAcccess = StrRoleAcccess + ","+Session["ArrayTobeSaved"].ToString();
...... //Saving those value in database
}}}


I am able maintain the status of all check boxes in every page on pagination...
I use RememberOldValues() and RestoreOldValues() function for that..


I am facing the problem when I retrieve all saved status of check boxes from database and show them when user select particular role from Combo box.

The status of selected Check boxes of first page get reflected but the status of check boxes on second page did not get reflected... one can say binding data to second page of grid view is not working.... Cry | :((

here is some part of coding
protected void CBRoleName_SelectedIndexChanged(object sender, EventArgs e)
{
Session["ArrayTobeSaved"] = "";
string[] StrArrOptionAcroName;string[] StrArrOptionName;string StrOptionName;
DataTable DtObjRAccess = CSUserRole.RoleAccesslist(CBRoleName.SelectedItem.Value);
GridView DemoGrid = new GridView();
DemoGrid.DataSource = DtObjRAccess;
int pageCount = GrdAccess.PageCount;
int DemoPageCount=0;

if (DtObjRAccess.Rows.Count > 0)
{
for (int RowCnt = 0; RowCnt < DtObjRAccess.Rows.Count; RowCnt++)
{
StrOptionName = DtObjRAccess.Rows[RowCnt].ItemArray[0].ToString();
if (StrOptionName != "")
{

StrArrOptionAcroName = StrOptionName.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
StrArrOptionName = new string[StrArrOptionAcroName.GetLength(0)];
var Optname = new ArrayList();
var AcroName = new ArrayList();
for (int index = 0; index < StrArrOptionAcroName.Length; index++)
{
StrArrOptionName = StrArrOptionAcroName[index].Split('_');
Optname.Add(StrArrOptionName[0]);
AcroName.Add(StrArrOptionName[1]);
}

for (int rowIndex = 0; rowIndex < Optname.Count; rowIndex++)
{ int i=0;
int j=0;
DemoPageCount = 0;
while (DemoPageCount < pageCount)
{
i=0;
j=9;

for(int p=i;p<=j;p++)
{
GridViewRow GrdRow= GrdAccess.Rows[p];
Label LblON = (Label)GrdRow.FindControl("lblAcronym");
if (LblON.Text == Optname[rowIndex].ToString())
{
int rdx = Convert.ToInt32(GrdRow.ID);
switch (AcroName[rowIndex].ToString())
{
case "C":
CheckBox objChk = (CheckBox)GrdRow.FindControl("ChkNew");
if (objChk.Enabled)
{ objChk.Checked = true; }
break;
case "E":
CheckBox objChkE = (CheckBox)GrdRow.FindControl("ChkEdit");
objChkE.Checked = true;
break;
case "D":
CheckBox objChkD = (CheckBox)GrdRow.FindControl("ChkDelete");
objChkD.Checked = true;
break;
}
}


}//end for
DemoPageCount++;
GrdAccess.PageIndex = DemoPageCount;
}//endwhile
}
//
}
}

}
}
else
{ }
}
...

Can u help me in this situation ......
AnswerRe: GridView Pagination Problem Pin
Abhijit Jana22-Sep-09 2:27
professionalAbhijit Jana22-Sep-09 2:27 
GeneralRe: GridView Pagination Problem Pin
sashidhar22-Sep-09 2:30
sashidhar22-Sep-09 2:30 
GeneralRe: GridView Pagination Problem Pin
Abhijit Jana22-Sep-09 2:35
professionalAbhijit Jana22-Sep-09 2:35 
GeneralRe: GridView Pagination Problem Pin
JMAboliEnrich22-Sep-09 20:22
JMAboliEnrich22-Sep-09 20:22 
QuestionIs it possible to maintain the treeview state Pin
Swetha Srinivasan22-Sep-09 1:19
Swetha Srinivasan22-Sep-09 1:19 
AnswerRe: Is it possible to maintain the treeview state Pin
Manas Bhardwaj22-Sep-09 1:25
professionalManas Bhardwaj22-Sep-09 1:25 
GeneralRe: Is it possible to maintain the treeview state Pin
Swetha Srinivasan22-Sep-09 2:46
Swetha Srinivasan22-Sep-09 2:46 
Questioncan we maintain value of file upload control in case of postback? Pin
keyur satyadev22-Sep-09 1:06
keyur satyadev22-Sep-09 1:06 
AnswerRe: can we maintain value of file upload control in case of postback? Pin
sashidhar22-Sep-09 1:13
sashidhar22-Sep-09 1:13 
GeneralRe: can we maintain value of file upload control in case of postback? Pin
keyur satyadev22-Sep-09 1:22
keyur satyadev22-Sep-09 1:22 
GeneralRe: can we maintain value of file upload control in case of postback? Pin
sashidhar22-Sep-09 1:43
sashidhar22-Sep-09 1:43 
GeneralRe: can we maintain value of file upload control in case of postback? Pin
Abhijit Jana22-Sep-09 1:26
professionalAbhijit Jana22-Sep-09 1:26 
GeneralRe: can we maintain value of file upload control in case of postback? Pin
sashidhar22-Sep-09 1:30
sashidhar22-Sep-09 1:30 
GeneralRe: can we maintain value of file upload control in case of postback? Pin
Abhijit Jana22-Sep-09 2:28
professionalAbhijit Jana22-Sep-09 2:28 
AnswerRe: can we maintain value of file upload control in case of postback? [modified] Pin
Chirantan Upadhyay15-Aug-10 22:25
Chirantan Upadhyay15-Aug-10 22:25 
QuestionConverter Pin
Amit Patel198522-Sep-09 0:58
Amit Patel198522-Sep-09 0:58 
AnswerRe: Converter Pin
Abhijit Jana22-Sep-09 1:14
professionalAbhijit Jana22-Sep-09 1:14 

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.