cross posted in datagrid group.
Inside <columns/> in my datagrid, I have the following template column
<asp:templateco lumn HeaderText="To Be Completed By">
<itemtemplate >
<asp:Label runat="server" Text='<%# DataBinder.Eval (Container,
"DataItem.FULL_ NAME") %>'><asp:label >
</itemtemplate>
<edititemtempla te>
<asp:dropdownli st ID="cboToBeComp letedBy"
Runat="server"> </asp:dropdownlis t>
</edititemtemplat e>
<asp:templateco lumn>
this template column is in cell 2 (0,1,2)
In my EditCommand event, I'd like to populate this dropdownlist. I call this
code
dgStatusIncompl ete.EditItemInd ex = e.Item.ItemInde x;
FetchSurveyStat usIncomplete(); // Populates the DataGrid
FetchUsersbyDep artment(
e.Item.Cells[2].FindControl("c boToBeCompleted By"),
e.Item.Cells[3].Text.ToString( ));
The problem is that e.Item.Cells[2].FindControl("c boToBeCompleted By") is
returning null, so the FetchUsersbyDep artment isn't receiving the drop down
list control as a parameter, it is incorrectly receiving null as a
parameter. Any idea?
private void FetchUsersbyDep artment(object control, string DeptId)
{
// Fetch Users for the Department
DataSet dsStaff = Department.Fetc hUsersbyDepartm ent(ConnectStri ng,
DeptId);
System.Web.UI.W ebControls.Drop DownList ctrl =
(System.Web.UI. WebControls.Dro pDownList)contr ol;
using (dsStaff)
{
if (dsStaff.Tables[0].Rows.Count > 0)
{
ctrl.DataSource = dsStaff;
ctrl.DataTextFi eld = "USER_NAME" ;
ctrl.DataValueF ield = "ID";
ctrl.DataBind() ;
}
}
}
Inside <columns/> in my datagrid, I have the following template column
<asp:templateco lumn HeaderText="To Be Completed By">
<itemtemplate >
<asp:Label runat="server" Text='<%# DataBinder.Eval (Container,
"DataItem.FULL_ NAME") %>'><asp:label >
</itemtemplate>
<edititemtempla te>
<asp:dropdownli st ID="cboToBeComp letedBy"
Runat="server"> </asp:dropdownlis t>
</edititemtemplat e>
<asp:templateco lumn>
this template column is in cell 2 (0,1,2)
In my EditCommand event, I'd like to populate this dropdownlist. I call this
code
dgStatusIncompl ete.EditItemInd ex = e.Item.ItemInde x;
FetchSurveyStat usIncomplete(); // Populates the DataGrid
FetchUsersbyDep artment(
e.Item.Cells[2].FindControl("c boToBeCompleted By"),
e.Item.Cells[3].Text.ToString( ));
The problem is that e.Item.Cells[2].FindControl("c boToBeCompleted By") is
returning null, so the FetchUsersbyDep artment isn't receiving the drop down
list control as a parameter, it is incorrectly receiving null as a
parameter. Any idea?
private void FetchUsersbyDep artment(object control, string DeptId)
{
// Fetch Users for the Department
DataSet dsStaff = Department.Fetc hUsersbyDepartm ent(ConnectStri ng,
DeptId);
System.Web.UI.W ebControls.Drop DownList ctrl =
(System.Web.UI. WebControls.Dro pDownList)contr ol;
using (dsStaff)
{
if (dsStaff.Tables[0].Rows.Count > 0)
{
ctrl.DataSource = dsStaff;
ctrl.DataTextFi eld = "USER_NAME" ;
ctrl.DataValueF ield = "ID";
ctrl.DataBind() ;
}
}
}