Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Professional
|
ASP.NET 1.0 and 1.1 Professional For advanced ASP.NET 1.x coders. Beginning-level questions will be redirected to other forums. NOT for "classic" ASP 3 or the newer ASP.NET 2.0 and 3.5
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 22nd, 2006, 05:49 AM
Authorized User
 
Join Date: Jan 2006
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default retaining values of controls inside a datagrid

Hi,
   i wanted to know how to retain the values of the web controls inside a datagrid.....there are a number of web controls inside a datagrid....if a put the method bindToGrid() inside the if(!Page.IsPostBack) then the values are being lost...
I have done this:
datagrid.DataSource=datatable;
datagrid.DataBind();
ProjectDetails projectdetail=new ProjectDetails();
DataTable[] datatable=new DataTable[5];
datatable[0]=projectdetail.getEmployeeProjectDetails(empId);
datatable[1]=projectdetail.getProjectName();
datatable[2]=projectdetail.getProjectManagerNames();
int i=0;
foreach(DataGridItem dgItem in grdProjectDetails.Items)
{
cboProjectName[i]=(DropDownList)dgItem.FindControl("cboProjects");
cboManagerName[i]=(DropDownList)dgItem.FindControl("cboManager");
releasedate[i]=(Aztec.Web.UI.WebControl.DatePicker.DatePickerCon trol)dgItem.FindControl("releaseDate");
chkIfBillable[i]=(CheckBox)dgItem.FindControl("chkAllBillable");
cboIfAvailable[i]=(DropDownList)dgItem.FindControl("cboAllAvailable ");
Rolloverdate[i]=(Aztec.Web.UI.WebControl.DatePicker.DatePickerCon trol)dgItem.FindControl("rollOverDate");
DataRow rows=datatable[0].Rows[i];
if(cboProjectName[i].DataValueField=="")
{
 cboProjectName[i].DataSource=datatable[1];
 cboProjectName[i].DataTextField= "projectName";
 cboProjectName[i].DataValueField= "projectId";
 cboProjectName[i].DataBind();
 cboProjectName[i].SelectedValue=rows[6].ToString();
}
if(cboManagerName[i].SelectedValue=="")
{
  cboManagerName[i].DataSource=datatable[2];
  cboManagerName[i].DataTextField= "empName";
  cboManagerName[i].DataValueField= "empId";
  cboManagerName[i].DataBind();
  cboManagerName[i].SelectedValue=rows[7].ToString();
}
if(releasedate[i].Text=="")
{
 releasedate[i].Text=rows[3].ToString();
}
if(rows[2].ToString()=="Yes")
{
 chkIfBillable[i].Checked=true;
}
else
{
 chkIfBillable[i].Checked=false;
}
if(rows[4].ToString()=="Available")
{
 cboIfAvailable[i].SelectedIndex=0;
 Rolloverdate[i].Text=rows[5].ToString();
}
else
{
 cboIfAvailable[i].SelectedIndex=1;
 Rolloverdate[i].Text="";
}
rowsId[i]=int.Parse(rows.ToString());
i++;
}

Now what happens is that when a press a button and the page is refreshed all the values of the arrays are lost. I have declared these arrays globally and initialized them on page load...


achhetri
__________________
achhetri





Similar Threads
Thread Thread Starter Forum Replies Last Post
User COntrol Datagrid inside datagrid rodmcleay ASP.NET 1.0 and 1.1 Professional 3 April 14th, 2007 10:11 AM
How to get to controls inside DataList? rsearing ASP.NET 2.0 Basics 1 March 1st, 2007 09:14 AM
find all the controls inside any table amartya_mandal ASP.NET 1.0 and 1.1 Professional 10 October 24th, 2006 08:35 AM
my session variables not retaining values nidhimittal Beginning PHP 4 July 7th, 2006 12:33 AM
my session variables not retaining values nidhimittal PHP How-To 5 June 22nd, 2006 12:35 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.