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

Radgrid PreRender - Selected Items Issue

3 Answers 300 Views
Grid
This is a migrated thread and some comments may be shown as answers.
dmc
Top achievements
Rank 1
dmc asked on 22 Oct 2012, 04:55 AM

I am using pre_render to set select items in a rad grid in a user control.  The method below is based on some Telerik posts.  The checkboxes are populated when the user control opens for me locally and on the production server using IE8.   But for other users (also using IE8), the check boxes only populate on postback.  I have tested using compatibility mode on and off and do not see a change in behavior. 

Any ideas or suggestions?  It is challenging that the code is the same but the behavior is varying for some users.

Protected 

Sub RadGrd_PreRender(sender As Object, e As System.EventArgs) Handles RadGrd.PreRender

     If Not (Session("SelectedItems_" + ClientID) Is Nothing) Then

        strSelectedItems = Session("SelectedItems_" + ClientID)

        For Each item As GridItem In RadGrd.MasterTableView.Items

            If TypeOf item Is GridDataItem Then

                Dim dataItem As GridDataItem = CType(item, GridDataItem)

                Dim chkBox As CheckBox = CType(dataItem("CheckBoxTemplateColumn").FindControl("CheckBox1"), CheckBox)

                If strSelectedItems.Contains("," + dataItem.OwnerTableView.DataKeyValues(dataItem.ItemIndex)("ID").ToString() + ",") Then

                    chkBox.Checked =

True
                               Else

                    chkBox.Checked = False

                End If

            End If

               Next

   End If

End Sub

 

3 Answers, 1 is accepted

Sort by
0
Radoslav
Telerik team
answered on 25 Oct 2012, 06:17 AM
Hello Dan,

Could you please verify that the ClientID variable used to get the session value (Session("SelectedItems_" + ClientID)) is the same before postback and after postback. Because if the ClientID is different the described behavior is expected. Also I suggest you to use static strings as keys. For example:
Session("SelectedItems_”). Please give it try and let me know if it helps you.

Looking forward for your reply.

Greetings,
Radoslav
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Ridwaan
Top achievements
Rank 1
answered on 19 Jan 2013, 10:19 AM
Hi there, on the selection issue I am having a problem that I cannot seem to understand

foreach (GridDataItem dataItem in gridsubcontatcs.Items)
        {
            if (dataItem.Selected ==true)
               
            {
                Array strtxt = dataItem["MOBILE_NO"].Text.ToArray()+";";
                Label1.Text = strtxt.ToString();
            }
        }

I want the selected Items to display next to each other eg: 1232434;12321213;213213
0
Shinu
Top achievements
Rank 2
answered on 21 Jan 2013, 08:50 AM
Hi,

Try the following code to achieve your scenario.
C#:
foreach (GridDataItem dataItem in gridsubcontatcs.Items)
{
            if (dataItem.Selected ==true)
            {
                string strtxt=dataItem["Mobile_NO"].Text;
             string s=strtxt.ToString();
              Label1.Text = Label1.Text +" ;" +s;
          }
}

Thanks,
Shinu
Tags
Grid
Asked by
dmc
Top achievements
Rank 1
Answers by
Radoslav
Telerik team
Ridwaan
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
Share this question
or