View Single Post
  #1 (permalink)  
Old March 22nd, 2006, 05:49 AM
@shish @shish is offline
Authorized User
 
Join Date: Jan 2006
Location: gangtok, Sikkim, India.
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