p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   ASP.NET 1.0 and 1.1 Professional (http://p2p.wrox.com/forumdisplay.php?f=57)
-   -   retaining values of controls inside a datagrid (http://p2p.wrox.com/showthread.php?t=40175)

@shish March 22nd, 2006 05:49 AM

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[8].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


All times are GMT -4. The time now is 08:16 PM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.