<MasterTableView AllowAutomaticUpdates="false" AllowAutomaticInserts="false" autogeneratecolumns="False" datasourceid="EditDataSource">
<columns>
<telerik:GridEditCommandColumn UniqueName="EditCommandColumn">
</telerik:GridEditCommandColumn>
<telerik:GridBoundColumn HeaderText="OrganizationName" HeaderButtonType="TextButton" DataField="OrganizationName">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn HeaderText="OrganizationName" HeaderButtonType="TextButton" DataField="ContactID">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn HeaderText="firstname" HeaderButtonType="TextButton" DataField="FirstName">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn HeaderText="lastname" HeaderButtonType="TextButton" DataField="LastName">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn HeaderText="Title" HeaderButtonType="TextButton" DataField="Title">
</telerik:GridBoundColumn>
</columns>
<EditFormSettings UserControlName="Contact.ascx" EditFormType="WebUserControl">
<EditColumn UniqueName="EditCommandColumn1"></EditColumn>
<PopUpSettings ScrollBars="None"></PopUpSettings>
</EditFormSettings>
</MasterTableView>
</telerik:RadGrid>
the details are displayed using a user control which looks like this:
private object _dataItem = null;
public object DataItem
{
get
{
return this._dataItem;
}
set
{
this._dataItem = value;
}
}
</script>
<table id="OrgTable">
<tr><td><strong>Contact Details:</strong></td></tr>
<tr>
<td>Contact ID</td>
<td><asp:TextBox id="ID" runat="server" Text='<%# DataBinder.Eval( Container, "dataItem.ContactID" ) %>'>
</asp:textbox></td>
<td>Prefix</td>
<td><asp:TextBox id="prefix" runat="server" Text='<%# DataBinder.Eval( Container, "dataItem.prefix" ) %>'>
</asp:textbox></td>
<td>First Name</td>
<td><asp:TextBox id="firstname" runat="server" Text='<%# DataBinder.Eval( Container, "dataItem.FirstName" ) %>'>
</asp:textbox></td>
</tr>
<tr>
<td>Middle Name</td>
<td><asp:TextBox id="middlename" runat="server" Text='<%# DataBinder.Eval( Container, "dataItem.MiddleName" ) %>'>
</asp:Textbox></td>
<td>Last Name</td>
<td><asp:TextBox id="lastname" runat="server" Text='<%# DataBinder.Eval( Container, "dataItem.LastName" ) %>'>
</asp:Textbox></td>
</tr>
<tr>
<td>Title</td>
<td><asp:TextBox id="title" runat="server" Text='<%# DataBinder.Eval( Container, "dataItem.Title" ) %>'>
</asp:Textbox></td>
</tr>
<tr>
<asp:Button CommandName="Update" runat="server" text="Update" />
</tr>
</table>
I am not sure how I can update the table on clicking the update button.
The code behind of the aspx has the following:
protected void RadGrid1_ItemUpdated(object source, GridCommandEventArgs e)
{
//Get the GridEditableItem of the RadGrid
GridEditableItem editedItem = (GridEditableItem)e.Item;
conn = new OleDbConnection(connectionstring);
conn.Open();
//Get the primary key value using the DataKeyValue.
// string ContactID = editedItem.OwnerTableView.DataKeyValues[editedItem.ItemIndex]["ContactID"].ToString();
//Access the textbox from the edit form template and store the values in string variables.
string FirstName = (editedItem.FindControl("FirstName ") as TextBox).Text;
string Title = (editedItem["Title"].Controls[0] as TextBox).Text;
//Open the SqlConnection
string updateQuery = "something ";
cmd = new OleDbCommand(updateQuery);
cmd.ExecuteNonQuery();
Close the SqlConnection
conn.Close();
}
The variables Firstname and Title don't have the updated values. I dont think the event is triggered when I click on the update button either. Any help would be greatly appreciated.
Thanks,