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

Non edit mode editing

2 Answers 88 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jon
Top achievements
Rank 1
Jon asked on 06 Jul 2011, 10:27 AM
Hi,
I have a grid that among the columns has 2 template columns that have editors present.  One of them selects whether or not the row is relevant and the other allows the entry of some text.  

This all works fine on the client but once the form comes back to the server I only see the original values that the controls in the 2 columns were set to - not any changed values.

The columns are as below (they get setup with the correct values via the ItemDataBound event):

<telerik:GridTemplateColumn DataField="Selected" HeaderText="Use?" UniqueName="uxSelected">
   <ItemTemplate>
      <asp:CheckBox ID="uxSelectedCheckbox" runat="server" Enabled="true" />
   </ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn DataField="SackColourRcGcBc" HeaderText="Custom Colour" UniqueName="uxSackColourRcGcBc">
   <ItemTemplate>
      <telerik:RadTextBox ID="uxSackColourRcGcBcTextbox" runat="server" Width="80px" AutoPostBack="False"/>
   </ItemTemplate>
</telerik:GridTemplateColumn>


The code behind is as below:

Dim idString As String = ""
Dim colourString As String = ""
Try
    For Each item As GridDataItem In DirectCast(uxFormView.FindControl("uxRadGrid"), RadGrid).Items
        Dim SackTypeID As String = item.GetDataKeyValue("SackTypeID").ToString()
 
        If CType(item("uxSelected").FindControl("uxSelectedCheckbox"), System.Web.UI.WebControls.CheckBox).Checked Then
            idString += SackTypeID + "!"
            If ConvertRGBToHTMLColour(CType(item("uxSackColourRcGcBc").FindControl("uxSackColourRcGcBcTextbox"), RadTextBox).Text) <> "" Then
                colourString += CType(item("uxSackColourRcGcBc").FindControl("uxSackColourRcGcBcTextbox"), RadTextBox).Text
            End If
            colourString += "!"
        End If
    Next
Catch ex As Exception
End Try


Any suggestions on what I'm doing wrong or if it can't be done like this.  If not I suppose that I can knock up some client side javascript to handle it but would prefer not to.  I've seen other examples and they seem to indicate that this should work..

Best Regards,

Jon

2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 06 Jul 2011, 11:54 AM
Hello Jon,

I am not quite sure about your requirement. Check the following help documentation which explains how to retain the state for checkbox control inside GridTemplateColumn which requires rebinding.
Persisting CheckBox control state in GridTemplateColumn on rebind.

Thanks,
Princy.
0
Jon
Top achievements
Rank 1
answered on 06 Jul 2011, 12:20 PM
Hi Princy,

Many thanks for that.  It looks like the kind of thing I need although I have a feeling that it will cause issues for me so may end up on that javascript path.  Either way this will be helpful!

Now if only the people that do the documentation would keep their samples simple and commented!

Best Regards,

Jon
Tags
Grid
Asked by
Jon
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Jon
Top achievements
Rank 1
Share this question
or