PDA

View Full Version : [CLOSED] Checkbox selection model is not working as expected.



arjunrvasisht
Apr 30, 2015, 4:57 AM
Hi,

I have a gridpanel which has to be loaded on a view button click. Below is the event code:


private void BindTier2()
{
int tmMonth;
int tmYear;

tmMonth = string.IsNullOrEmpty(CmbMonth.SelectedItem.Value) ? -1 : int.Parse(CmbMonth.SelectedItem.Value);
tmYear = string.IsNullOrEmpty(CmbYear.SelectedItem.Value) ? -1 : int.Parse(CmbYear.SelectedItem.Value);

PBView objPBViews = new AP3.Core.Bll.Mbm.PBView();
DataTable dtTierMapping = new DataTable();
dtTierMapping = objPBViews.GetETmetricsTier2Mapping(tmMonth, tmYear);

str2TierMapping.RemoveAll();



str2TierMapping.DataSource = dtTierMapping;
str2TierMapping.DataBind();

RowSelectionModel sm = this.grdTier2Mapping.SelectionModel.Primary as RowSelectionModel;
sm = this.grdTier2Mapping.SelectionModel.Primary as RowSelectionModel;
sm.SelectedRow = new SelectedRow(2);
sm.SelectedRows.Add(new SelectedRow(0));
sm.SelectedRows.Add(new SelectedRow(2));
}


I have a checkbox selection model in the gridpanel and I want some of the rows to be automatically checked while loading. If I call the above function in a page load it is working fine. But When I call the same function inside a view button click event only the grid is loading but the check boxes are not being checked. Please help.

Daniil
Apr 30, 2015, 11:23 AM
Hi @arjunrvasisht,

During a DirectEvent you should also call

sm.UpdateSelectedRows();
at the end.

It should not be called on the initial Page_Load, though.

arjunrvasisht
Apr 30, 2015, 11:32 AM
That fixed my problem. Thanks :)