This is a migrated thread and some comments may be shown as answers.

SelectedItems empty with client side row select

3 Answers 194 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Aldert
Top achievements
Rank 2
Aldert asked on 13 Oct 2008, 11:05 AM
Hi,

I think I'm overseeing a very simple thing here, but I just cannot get the SelectedItems collection filled....

I have the following control:
<telerik:RadGrid ID="grdTemplates" runat="server" AutoGenerateColumns="False" GridLines="None" AllowMultiRowSelection="false"AllowSorting="false" OnNeedDataSource="grdTemplates_NeedDataSource" OnItemDataBound="grdTemplates_ItemDataBound" OnItemCommand="grdTemplates_ItemCommand">
<ClientSettings
>
    <Selecting AllowRowSelect="True"></Selecting
>
</ClientSettings>


The selection client-side is not problem. But when I click on the Next button on the screen, the grdTemplates.SelectedItems.Count is always 0.

Can somebody please tell me what I'm doing wrong?

Kind regards,

Aldert Polman


3 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 13 Oct 2008, 01:07 PM
Hello Aldert,

Let us know in which event handler you are performing this check. Depending on the particular case you may need to set EnablePostBackOnRowClick property in order to achieve the functionality.
<ClientSettings EnablePostBackOnRowClick="True"

Regards,
Daniel
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Aldert
Top achievements
Rank 2
answered on 13 Oct 2008, 01:39 PM
Hi Daniel,

Thanks for the quick response!

I have a button on the same panel as the RadGrid control:

 

<asp:Button ID="btnComplete" runat="server" onclick="btnComplete_Click" Enabled="false" />

 

In the code behind I have the following code:

 

protected void btnComplete_Click(object sender, EventArgs e)
{
PeterBlum.DES.
Globals.Page.Validate();
if (PeterBlum.DES.Globals.Page.IsValid == true)
{
    currentProject.TemplateId = 100;
    currentProject.Save();
    Response.Redirect(
"~/pages/project/projectsquare.aspx?project="
            currentProject.ProjectId.ToString() +
"&verification="
            currentProject.ExternalTestId.ToString());
}
}

 

I want to have the grdTemplates.SelectedValue on the hardcoded 100.

I placed the EnablePostBackOnRowClick="True" in the code and this raised:

 

public void grdTemplates_ItemCommand(object sender, GridCommandEventArgs e)

 

I can make a workaround that uses this event, but if there is a proper solution I would prefer that one.

Kind regards,

Aldert
0
Daniel
Telerik team
answered on 16 Oct 2008, 09:00 AM
Hello Aldert,

The SelectedItems collection is updated on server-side after a postback occurs.
Regarding the SelectedValue property - it is read-only and it is not possible to assign values to.

Also note that if you handled SelectedIndexChanged without EnablePostBackOnRowClick set to true the mentioned event won't raise until the next postback.

Finally, you may experience such issues if your ViewState is disabled.

Let me know whether this clarification is helpful.

Best regards,
Daniel
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
Aldert
Top achievements
Rank 2
Answers by
Daniel
Telerik team
Aldert
Top achievements
Rank 2
Share this question
or