How to status of Checkbox of itemcolumn in webpart
HI,
I Have DataGrid webpart with Itemtemplate Column with Checkbox as the item.after databinding to the datagrid, i am checking the status of the checkbox.but i am getting always false value from the checkbox.
please help me regarding this
I am Useing the following code......
//-----------to check the status.........
foreach(DataGridItem item in UserDataGrid.Items)
{
// HtmlInputCheckBox chk;
//chk=(HtmlInputCheckBox)item.Cells[0].FindControl("chkNaveen") ;
CheckBox selected=(CheckBox)item.FindControl("chkNaveen");
if(!selected.Checked)
{
System.Web.HttpContext.Current.Response.Write("Nav een");
//deleted = _oLNService.DeleteUserMailData(UserName,DkValue);
}
}
//----------adding the template column dynamically...........
tcol.HeaderText="Delete";
tcol.ItemStyle.HorizontalAlign=HorizontalAlign.Cen ter;
tcol.ItemTemplate = mycol;
//tcol.HeaderTemplate=myheader;
UserDataGrid.Columns.Add(tcol);
//-----------template column Class.........
public class ColumnTemplate : ITemplate
{
private ListItemType itemType;
string strText;
string strCheckboxName;
bool Visibility = true;
bool blChecked= false;
// public ColumnTemplate(string CheckboxName,string Text,bool AutoCheck)
// {
// this.strText =Text;
// this.strCheckboxName=CheckboxName;
// this.blChecked=AutoCheck;
// }
public void InstantiateIn(Control container)
{
CheckBox mycheckbox = new CheckBox();
//HtmlInputCheckBox mycheckbox = new HtmlInputCheckBox();
mycheckbox.DataBinding+=new EventHandler(mycheckbox_DataBinding);
container.Controls.Add(mycheckbox);
container.EnableViewState=true;
}
}
|