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 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.
*****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 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.