I have a created a radgrid with editing capabilities. Once the user updates the item I am unable to get the edited values.
My code is listed below
ASPX Code
<telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="False" GridLines="None"
OnItemDataBound="RadGrid1_ItemDataBound" OnNeedDataSource="RadGrid1_NeedDataSource"
AllowSorting="True" AllowAutomaticInserts="True" AllowAutomaticUpdates="True"
AutoGenerateEditColumn="true" OnItemUpdated="RadGrid1_ItemUpdated" OnUpdateCommand="RadGrid1_UpdateCommand">
<MasterTableView DataKeyNames="username" Width="100%" EditMode="InPlace">
<RowIndicatorColumn>
<HeaderStyle Width="20px"></HeaderStyle>
</RowIndicatorColumn>
<ExpandCollapseColumn>
<HeaderStyle Width="20px"></HeaderStyle>
</ExpandCollapseColumn>
<Columns>
<telerik:GridBoundColumn DataField="username" HeaderText="User Name" UniqueName="username" ReadOnly=true>
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="password" HeaderText="Password" UniqueName="password">
</telerik:GridBoundColumn>
<telerik:GridTemplateColumn HeaderText="Password" UniqueName="TemplateColumn">
<ItemTemplate>
<asp:DropDownList ID="DropDownList1" runat="server">
</asp:DropDownList>
</ItemTemplate>
</telerik:GridTemplateColumn>
</Columns>
</MasterTableView>
</telerik:RadGrid>
C# Code
protected
void RadGrid1_UpdateCommand(object source, GridCommandEventArgs e)
{
//Get the GridEditableItem of the RadGrid
GridEditableItem editedItem = e.Item as GridEditableItem;
//Get the primary key value using the DataKeyValue.
string sUserName = editedItem.OwnerTableView.DataKeyValues[editedItem.ItemIndex]["username"].ToString();
//Access the textbox from the edit form template and store the values in string variables.
string sPassword = (editedItem["password"].Controls[0] as TextBox).Text;
}
Any help is much appreciated.
Regards,
Kaushik
| <MasterTableView ClientDataKeyNames="IdContact" GroupLoadMode="Client" | |
| NoMasterRecordsText="" ShowHeadersWhenNoRecords="true" Width="100%"> | |
| <GroupByExpressions> | |
| <telerik:GridGroupByExpression> | |
| <SelectFields> | |
| <telerik:GridGroupByField FieldAlias="MembreConvers" FieldName="MembreConvers" | |
| HeaderText="Participe" /> | |
| </SelectFields> | |
| <GroupByFields> | |
| <telerik:GridGroupByField FieldName="MembreConvers" /> | |
| </GroupByFields> | |
| </telerik:GridGroupByExpression> | |
| </GroupByExpressions> | |
| <Columns> | |
| <telerik:GridMaskedColumn DataField="MembreConvers" | |
| SortExpression="MembreConvers"> | |
| </telerik:GridMaskedColumn> | |
| <!-- Continue --> |
| //Called When WebService GetContactListForConversation return | |
| function SucceededCallbackGetParticipants(result, eventArgs) { | |
| //Conversation ID - and so window - is in eventArgs. | |
| //It allows us to get current conversation's radWindow | |
| var radWindowManager = GetRadWindowManager(); | |
| var window_ = radWindowManager.getWindowById(eventArgs); | |
| if (window_ != null) { | |
| //Get the frame | |
| var frame = window_.get_contentFrame(); | |
| //Get the window | |
| var windowContent_ = frame.contentWindow; | |
| var radGrid = windowContent_.$find("RadGridContacts"); | |
| //Get Master TableView | |
| var tableView = radGrid.get_masterTableView(); | |
| //Set dataSource and DataBind | |
| tableView.set_dataSource(result); | |
| tableView.dataBind(); | |
| //Using setTimeout instead of setInterval(firefox compatible) | |
| setTimeout(function() { GetParticipantsForConversation(eventArgs) }, timeout); | |
| } |
| public class Contact | |
| { | |
| public string NomPrenom { get; set; } | |
| public int IdContact { get; set; } | |
| public string EnLigne { get; set; } | |
| public string MembreConvers { get; set; } | |
| // Continue here .... | |
| } |
| //Test | |
| List<Contact> contactsList = new List<Contact>(); | |
| //there will be 2 groups : "Oui" and "Non". | |
| contactsList.Add(new Contact("", 0, true, "Oui")); | |
| contactsList.Add(new Contact("", 0, true, "Non")); RadGridContacts.MasterTableView.DataSource = contactsList; | |
| /*And when I'm updating Client-side, group "Oui" and "Non" are limited to 1 item each. How can I fill them client-side?*/ |