| <ItemStyle BackColor="Black" ForeColor="Red" /> <AlternatingItemStyle BackColor="White" /> |
| tr.GridAltRow_Default |
| { |
| color: Black; |
| background-color: White; |
| background-image: none; |
| } |
| <telerik:RadComboBox ID="cbM0016" runat="server" |
| EmptyMessage="Select Branch" HighlightTemplatedItems="true" |
| AllowCustomText="true" Enabled="false" Skin="Outlook" Width="100%" > |
| <ItemTemplate> |
| <asp:CheckBox runat="server" ID="chk1" Checked="true" onclick="onCheckBoxClickM0016(this)"/> |
| <asp:Label runat="server" ID="lbl1" Text='<%#DataBinder.Eval(Container.DataItem, "BranchNameAndID")%>'/> |
| </ItemTemplate> |
| </telerik:RadComboBox> |
| function onCheckBoxClickM0016(sender) { |
| var combo = $find("<%= cbM0016.ClientID %>"); |
| //holds the text of all checked items |
| var text = ""; |
| //holds the values of all checked items |
| var values = ""; |
| //get the collection of all items |
| var items = combo.get_items(); |
| //get the ALL checkbox |
| var chk1 = $get(combo.get_id() + "_i0" + "_chk1"); |
| if (chk1.checked && sender.id == "cbM0016_i0_chk1") { |
| text = "ALL"; |
| //enumerate all items |
| for (var i = 1; i < items.get_count(); i++) { |
| var item = items.getItem(i); |
| //get the checkbox element of the current item |
| var chk2 = $get(combo.get_id() + "_i" + i + "_chk1"); |
| chk2.checked = true; |
| values += item.get_value() + ","; |
| } |
| } |
| else { |
| var count = 0; |
| //enumerate all items |
| for (var i = 1; i < items.get_count(); i++) { |
| var item = items.getItem(i); |
| //get the checkbox element of the current item |
| var chk2 = $get(combo.get_id() + "_i" + i + "_chk1"); |
| if (chk2.checked) { |
| count += 1; |
| text += item.get_text() + ","; |
| values += item.get_value() + ","; |
| } |
| } |
| if (count == i - 1 && sender.id != "cbM0016_i0_chk1") { |
| chk1.checked = true; |
| } |
| else { |
| chk1.checked = false; |
| } |
| } |
| //remove the last comma from the string |
| text = removeLastComma(text); |
| values = removeLastComma(values); |
| if (text.length > 0) { |
| //set the text of the combobox |
| if (chk1.checked) { |
| combo.set_text("ALL"); |
| } else { |
| combo.set_text(text); |
| } |
| } |
| else { |
| //all checkboxes are unchecked |
| //so reset the controls |
| combo.set_text(""); |
| } |
| combo.set_value(values); |
| } |
<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,