I placed a radcombobox inside a radgrid.I have autopostback set to true. I am using a GridTemplateColumn inside that I have filtertemplate inside that I placed a radcombobox .I also have itemtemplate inside that I have a checkbox.The combobox is populated with three values attended,unattended and all.when I select unattended/all in radcombobox it is showing the selectedvalue as attended only after postback.If attended is selected in radcombobox then the check boxes appears as checked.If unattended is selected from radcombobox then the checkboxes appears as unchecked.Please let me know what is wrong here.urgent please...
Here is the lines of code of importance
<telerik:GridTemplateColumn ShowFilterIcon="false" HeaderText="Attendance" CurrentFilterFunction="EqualTo">
<FilterTemplate>
<telerik:RadComboBox ID="cmbAttend" runat="server" DataTextField="ATTENDANCE_TYPE_DESC" DataValueField="ATTENDANCE_TYPE_ID"
EnableViewState="true" AutoPostBack="true">
</telerik:RadComboBox>
</FilterTemplate>
<ItemTemplate>
<asp:CheckBox ID="chkAttend" runat="server" />
</ItemTemplate>
</telerik:GridTemplateColumn>
aspx code
<telerik:RadGrid ID="gvEventHistory" skin ="Default" runat="server" AutoGenerateColumns="false" AllowPaging="true" AllowSorting="true" PageSize="100"
AllowFilteringByColumn="true" OnItemDataBound="gvEventHistory_ItemDataBound" OnItemCreated="gvEventHistory_ItemCreated" OnNeedDataSource="gvEventHistory_NeedDataSource">
<GroupingSettings CaseSensitive="false" />
<MasterTableView DataKeyNames="SCHEDULE_EVENT_ID" ClientDataKeyNames="SCHEDULE_EVENT_ID" AllowFilteringByColumn="True">
<RowIndicatorColumn>
<HeaderStyle Width="2px" />
<ItemStyle Width ="10px" />
</RowIndicatorColumn>
<Columns>
<telerik:GridTemplateColumn ShowFilterIcon="false" HeaderText="Attendance" CurrentFilterFunction="EqualTo">
<FilterTemplate>
<telerik:RadComboBox ID="cmbAttend" runat="server" DataTextField="ATTENDANCE_TYPE_DESC" DataValueField="ATTENDANCE_TYPE_ID"
EnableViewState="true" AutoPostBack="true">
</telerik:RadComboBox>
</FilterTemplate>
<ItemTemplate>
<asp:CheckBox ID="chkAttend" runat="server" />
</ItemTemplate>
</telerik:GridTemplateColumn>
</Columns>
</MasterTableView>
<ClientSettings Selecting-AllowRowSelect="true">
</ClientSettings>
</telerik:RadGrid>
C# code
protected void Page_Load(object sender, EventArgs e)
{
aEmpNo = Convert.ToInt32(Request.QueryString["empno"]);
if (!Page.IsPostBack)
{
//Load all events default view
m_EmpEventHistoryList = EmployeeEventHistoryManager.Instance.GetEventHistory(aEmpNo );
gvEventHistory.DataSource = m_EmpEventHistoryList;
gvEventHistory.DataBind();
}
}
protected void gvEventHistory_NeedDataSource(object source, GridNeedDataSourceEventArgs e)
{
m_EmpEventHistoryList = EmployeeEventHistoryManager.Instance.GetEventHistory(this.EmployeeNoParameter);
gvEventHistory.DataSource = m_EmpEventHistoryList;
}
protected void gvEventHistory_ItemDataBound(object sender, GridItemEventArgs e)
{
RadComboBox cmbEventType = null;
RadComboBox cmbAttend = null;
string aAttendValue = string.Empty;
int aIndex = 0;
string SelectedValue = "1";
//Get the eventtypedesc from event_type table
//GetScheduleEvent will bring all the events and bind it to combobox
IList<ScheduleEvent> m_ScheduleList = ScheduleEventManager.Instance.GetScheduleEvent();
//Get this list and bind them to cmbattend combobox which contains attended,unattended
//all rows
IList<EmployeeEventHistory> m_EmployeeEventAttendedList = EmployeeEventHistoryManager.Instance.GetEventAttendedDetails();
if (e.Item is GridFilteringItem)
{
cmbAttend = (RadComboBox)e.Item.FindControl("cmbAttend");
cmbAttend.DataSource = m_EmployeeEventAttendedList;
cmbAttend.DataBind();
}
}protected void gvEventHistory_ItemCreated(object sender, GridItemEventArgs e)
{
RadComboBox cmbEventType = null;
RadComboBox cmbAttend = null;
if (e.Item is GridFilteringItem)
{
//Get the cmbAttend RadComboBox
cmbAttend = (RadComboBox)e.Item.FindControl("cmbAttend");
cmbAttend.ID = "cmbAttend";
cmbAttend.SelectedIndexChanged += new RadComboBoxSelectedIndexChangedEventHandler(cmbAttend_SelectedIndexChanged);
}
}
void cmbAttend_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e)
{
IList<WW.FS.SPSS.Business.Employee.EmployeeEventHistory> m_EmpEventHistoryList = null;
string All = "All";
int Attended = 1;
int UnAttended = 2;
RadComboBox cmbAttend = (RadComboBox)o;
int aAttendTypeId = 0;
int aCounter = 0;
//If All is selected then this code block must be executed
if (cmbAttend.Text.ToString().ToUpper().Trim() == All.ToUpper().Trim())
{
aAttendTypeId = Convert.ToInt32(cmbAttend.SelectedValue.ToString());
m_EmpEventHistoryList = EmployeeEventHistoryManager.Instance.GetEmpEventAttendance(aAttendTypeId);
foreach (GridDataItem aGridItem in gvEventHistory.Items)
{
if (aGridItem.ItemType == GridItemType.Item)
{
CheckBox chkAttended = (CheckBox)aGridItem.FindControl("chkAttend");
if (chkAttended != null)
{
if (Convert.ToString(m_EmpEventHistoryList[aCounter].ATTENDANCE_TYPE_ID).ToUpper().Trim() == Convert.ToString(Attended).ToUpper().Trim())
{
chkAttended.Checked = true;
}
else
if (Convert.ToString(m_EmpEventHistoryList[aCounter].ATTENDANCE_TYPE_ID).ToUpper().Trim() == Convert.ToString(UnAttended).ToUpper().Trim())
{
chkAttended.Checked = false;
}
}
}
}
gvEventHistory.DataSource = m_EmpEventHistoryList;
gvEventHistory.DataBind();
Thanks and Regards
Sri