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

radgrid commandevent not working

2 Answers 80 Views
Grid
This is a migrated thread and some comments may be shown as answers.
erol
Top achievements
Rank 1
erol asked on 01 Jun 2011, 02:45 PM
Hello, I have a radgrid that is being populated with a mysql odbc datasource. I am trying to get the update command to update information from my edited item to the database. as of right now, if you click edit, the item goes into edit mode. if you add text then click update, it postsback, but no data is loaded to the database. I need this to work as an itemCommand "Update" in a select case as I need to dynamically populate data to be added through another function. I have tried using just a standard "OnUpdate" but that also is not working. here is the offending code, HELP PLEASE 




*****Previous Code*****

  Protected Sub gridfflistings_UpdateCommand(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs)
        Dim editedItem As GridEditableItem = CType(e.Item, GridEditableItem)
        Dim rowid As String = gridfflistings.MasterTableView.DataKeyValues(e.Item.ItemIndex)("propertyid")
        Dim Dlink As String = editedItem("txtlink").Text
        Dim add1 As String = editedItem("address").Text
        Dim propid As String = rowid.ToString
        Dim upstr As String = "update fflistings set mlsnumber=?, directlink=? where propertyid=?;"
        Dim upcon As New OdbcConnection(sConnectionString)
        upcon.Open()
        Using upcom As New OdbcCommand(upstr, upcon)
            upcom.Parameters.AddWithValue("mlsnumber", "11111")
            upcom.Parameters.AddWithValue("directlink", Dlink.ToString)
            upcom.Parameters.AddWithValue("propid", rowid.ToString)
            Try
                upcom.ExecuteNonQuery()
                gridfflistings.Rebind()
                lbldebug.Text = " updated information"
                upcon.Close()
            Catch ex As Exception
                lbldebug.Text = "There was an issue updating the db" & ex.Message
            End Try
        End Using
    End Sub



******the grid*****

<telerik:radgrid id="gridfflistings" datasourceid="sqlfflistings" runat="server" width="800px" OnUpdateCommand="gridfflistings_UpdateCommand" AllowAutomaticUpdates="false">                
                <MasterTableView DataSourceID="sqlfflistings" DataKeyNames="propertyid" AutoGenerateColumns="false" EditMode="EditForms" >
                <columns>
                <telerik:GridEditCommandColumn ButtonType="ImageButton" >               
                </telerik:GridEditCommandColumn>               
                <telerik:GridBoundColumn HeaderText="Property ID" datafield="propertyid" readonly="true" visible="true"></telerik:GridBoundColumn>
                <telerik:GridBoundColumn HeaderText="Address" datafield="address1" uniquename="address" readonly="true"></telerik:GridBoundColumn>
                <telerik:GridBoundColumn HeaderText="City" datafield="city" readonly="true"></telerik:GridBoundColumn> 
                <telerik:GridBoundColumn HeaderText="State" DataField="state" readonly="true"></telerik:GridBoundColumn>
                <telerik:GridBoundColumn HeaderText="Zip Code" DataField="Zipcode" readonly="true"></telerik:GridBoundColumn>
                <telerik:GridBoundColumn HeaderText="M6P ID" DataField="m6plistingid" readonly="true"></telerik:GridBoundColumn>
                <telerik:GridBoundColumn HeaderText="MLS" DataField="mlsnumber" ReadOnly="true" ></telerik:GridBoundColumn>
                <telerik:GridBoundColumn HeaderText="Direct Link" DataField="directlink" UniqueName="directlink" ColumnEditorID="newlink" Visible="false" ReadOnly="true"></telerik:GridBoundColumn>
                <telerik:GridTemplateColumn UniqueName="newlink" headertext="Direct Link">
                    <ItemTemplate>
                        <asp:Label ID="lbllink" runat="server"></asp:Label>
                    </ItemTemplate>
                    <EditItemTemplate>
                        <asp:TextBox ID="txtlink" runat="server"></asp:TextBox>
                    </EditItemTemplate>
                </telerik:GridTemplateColumn>
                <telerik:GridCheckBoxColumn HeaderText="Paid" DataField="pstatus" readonly="true"></telerik:GridCheckBoxColumn>
                </columns>
                </MasterTableView>
                </telerik:radgrid>

I have changed the code as follows to try and use a custom edit form to see if that would fix the issue. I have done some testing and it is updating data to the db, it is just NOT capturing the data from the edit form. It keeps applying a &nbsp; to the db instead of the values needed. I have altered the code above to the new code, PLEASE HELP! I have to get this function finished TODAY!!!!!!  now when I click the update button it does not leave edit mode. 

2 Answers, 1 is accepted

Sort by
0
erol
Top achievements
Rank 1
answered on 01 Jun 2011, 02:54 PM
I have also tried added labels to the page, and setting the event to populate the label with some text, which also does not happen.
0
Iana Tsolova
Telerik team
answered on 06 Jun 2011, 08:35 AM
Hi erol,

I reviewed your code and I find it correct. Based on it I cannot find a reason for the UpdateCommand event of the grid not to fire when the Update button is clicked.
Can you elaborate if the grid is defined in a content page in master/content page scenario? Also, what is the .NET version for the web site? If it is built under .NET 4.0, make sure the page ClientIDMode is set to AutoID and see if it makes any difference.
You can try pasting the whole page and related code for further check.

Regards,
Iana
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Tags
Grid
Asked by
erol
Top achievements
Rank 1
Answers by
erol
Top achievements
Rank 1
Iana Tsolova
Telerik team
Share this question
or