Hello, I have a challenge invloving a grid that is nested underneath a panelbal that is, in turn inside a multiview. I am using the PopUp Edit functionality with the Edit Template nested inside the MasterTableView.
To access the Edit Form from this grid, I am using the AutoGenerated edit button. Upon clicking the button, after the AjaxLoadpanel fires and the page is re-rendered the Edit Template appears as a Modal PopUp, as required.
The challenge comes in the ItemCommand event handler for the grid, after making a change in the Edit form, and clicking the button that I have designated for Updating the necessary objects and sending off to the database. I am not using a SqlDataSource. I am running the MVP architecture (not MS MVC) and all of the necessary postback actions happen as required.
Here is the page with the necessary parts:
My apologies for the alignment, and missing tags :/
Here is the code to populate the grid:
Here is the code for the ItemCommand Handler method of the grid:
Everything LOOKS correct, and actually provides access to the necessary controls in the template. However, if I change anything in the Edit form, that edits are not available to me on the postback. Any Suggestions?
To access the Edit Form from this grid, I am using the AutoGenerated edit button. Upon clicking the button, after the AjaxLoadpanel fires and the page is re-rendered the Edit Template appears as a Modal PopUp, as required.
The challenge comes in the ItemCommand event handler for the grid, after making a change in the Edit form, and clicking the button that I have designated for Updating the necessary objects and sending off to the database. I am not using a SqlDataSource. I am running the MVP architecture (not MS MVC) and all of the necessary postback actions happen as required.
Here is the page with the necessary parts:
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server"> |
<telerik:RadSplitter ID="RadSplitter1" runat="server" Width="100%" Height="100%" |
ResizeMode="EndPane" Skin="Default" Font-Size="Large" BorderStyle="None"> |
<telerik:RadSplitBar ID="RadSplitBar2" runat="server" CollapseMode="Forward" /> |
<telerik:RadPane ID="rdpFollowData" runat="server" Scrolling="Y" Height="590px"> |
<telerik:RadTabStrip ID="tbFollowData" runat="server" |
MultiPageID="rdmultFollowup" SelectedIndex="0" |
Width="100%" AutoPostBack="False" > |
<tabs> |
<telerik:RadTab PageViewID="rpvSeller" Text="Seller Details"> |
</telerik:RadTab> |
</tabs> |
</telerik:RadTabStrip> |
<telerik:RadMultiPage ID="rdmultFollowup" runat="server" SelectedIndex="0" Width="100%"> |
<telerik:RadPageView ID="rpvSeller" runat="server"> |
<telerik:RadPanelBar ID="rpbSeller" runat="server" Skin="Default" |
Style="float:left" Width="100%"> |
<Items> |
<telerik:RadPanelItem ImagePosition="Right" Text="General"> |
<Items> |
<telerik:RadPanelItem Value="General" runat="server"> |
<ItemTemplate> |
<asp:Button ID="btnAddOwner" runat="server" Text="Add Seller" /><br /> |
<telerik:RadGrid ID="rgSeller" runat="server" AutoGenerateColumns="False" AutoGenerateEditColumn="true" GridLines="None" OnDataBound="rgSeller_DataBound" OnItemDataBound="rgSeller_ItemDataBound" OnNeedDataSource="rgSeller_NeedDataSource" OnItemCommand="rgSeller_ItemCommand" EditItemStyle-Width="300px"> |
<ClientSettings> |
<ClientEvents OnRowDblClick="RowDblClick" /> |
</ClientSettings> |
<MasterTableView Height="100%" Width="50%" EditMode="PopUp" > |
<EditFormSettings CaptionFormatString="Edit User: {0}" CaptionDataField="UserID" EditFormType="Template" PopUpSettings-Modal="true"> |
<FormTemplate> |
<table id="editForm" width="400px"> |
<tr> |
<td align="left"> |
First Name: <asp:TextBox ID="txtFirstname" runat="server" Text='<%# Bind("FirstName") %>'></asp:TextBox> |
</td> |
</tr> |
<tr> |
<td align="left"> |
Last Name : <asp:TextBox ID="txtLastname" runat="server" Text='<%# Bind("LastName") %>'></asp:TextBox> |
</td> |
</tr> |
<tr> |
<td align="left" colspan="3"> |
Mailing Address : <asp:TextBox ID="txtAddress" Width="250px" runat="server" |
Text='<%# Bind("MailAddress") %>' />, |
<asp:TextBox ID="txtCity" Width="250px" runat="server" Text='<%# Bind("MailCity") %>' />, |
<asp:TextBox ID="txtState" Width="25px" runat="server" Text='<%# Bind("MailState") %>' />, |
<asp:TextBox ID="txtZip" Width="50px" runat="server" Text='<%# Bind("MailZip") %>' /> |
</td> |
</tr> |
<tr> |
<td align="left"> |
<telerik:RadGrid ID="rgPhones" runat="server" Skin="Default" > |
<MasterTableView GridLines="Horizontal" Frame="Void" NoMasterRecordsText="No Phone Numbers Listed" |
AutoGenerateColumns="false" Width="100%"> |
<Columns> |
<telerik:GridBoundColumn DataField="PhoneID" Visible="false" /> |
<%--<telerik:GridButtonColumn ButtonType="LinkButton" Text="Delete" />--%> |
<telerik:GridBoundColumn HeaderText="Phone Number" DataField="Phone" /> |
</Columns> |
</MasterTableView> |
</telerik:RadGrid> |
<asp:Button ID="btnAddUserPhone" runat="server" Text="Add Phone" /> |
</td> |
</tr> |
<tr> |
<td align="left"> |
Username : <asp:TextBox ID="txtUsername" runat="server" Text='<%# Bind("UserName")%>'></asp:TextBox> |
</td> |
</tr> |
<tr> |
<td colspan="3" align="left"> |
Email : <asp:TextBox ID="txtEmail" runat="server" Text='<%# Bind("Email") %>'></asp:TextBox> |
</td> |
</tr> |
<tr> |
<td colspan="3" align="right"> |
<asp:Button ID="btnResetPassword" runat="server" Text="Reset Password" CommandName="ResetPassword" /> |
<asp:Button ID="btnUpdateUser" runat="server" Text="Update" CommandName="UpdateUser"/> |
<asp:Button ID="btnCanc" runat="server" Text="Cancel" CommandName="Cancel"/> |
</td> |
</tr> |
</table> |
</FormTemplate> |
</EditFormSettings> |
<Columns> |
<telerik:GridBoundColumn DataField="UserID" Visible="false"/> |
<telerik:GridBoundColumn DataField="FirstName" HeaderText="FirstName" EditFormColumnIndex="0"/> |
<telerik:GridBoundColumn DataField="LastName" HeaderText="FirstName" EditFormColumnIndex="0"/> |
</Columns> |
</MasterTableView> |
</telerik:RadGrid> |
</ItemTemplate> |
</telerik:RadPanelItem> |
</Items> |
</telerik:RadPanelItem> |
</Items> |
</telerik:RadPanelBar> |
</telerik:RadPageView> |
</telerik:RadPane> |
</telerik:RadSplitter> |
<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server"> |
<script type="text/javascript"> |
function RowDblClick(sender, eventArgs) { |
sender.get_masterTableView().editItem(eventArgs.get_itemIndexHierarchical()); |
} |
</script> |
</telerik:RadCodeBlock> |
</asp:Content> |
Here is the code to populate the grid:
private void ShowSellerData(List<Users> sellers, List<PhoneNumbers> phones) |
{ |
RadPanelItem pnl = rpbSeller.FindItemByValue("General"); |
RadGrid grid = pnl.FindControl("rgSeller") as RadGrid; |
grid.DataSource = sellers; |
grid.DataBind(); |
//some other ancilliary methods |
} |
Here is the code for the ItemCommand Handler method of the grid:
protected void rgSeller_ItemCommand(object source, GridCommandEventArgs e) |
{ |
switch (e.CommandName) |
{ |
case "UpdateUser": |
string fn, ln, addr, city, st, zip, unm, email; |
GridDataItem item = e.Item as GridDataItem; |
GridEditFormItem editor = item.EditFormItem; |
int uid = 0; |
TextBox txt = editor.FindControl("txtFirstname") as TextBox; |
fn = txt.Text; |
txt = editor.FindControl("txtLastname") as TextBox; |
ln = txt.Text; |
txt = editor.FindControl("txtAddress") as TextBox; |
addr = txt.Text; |
txt = editor.FindControl("txtCity") as TextBox; |
city = txt.Text; |
txt = editor.FindControl("txtState") as TextBox; |
st = txt.Text; |
txt = editor.FindControl("txtZip") as TextBox; |
zip = txt.Text; |
txt = editor.FindControl("txtUsername") as TextBox; |
unm = txt.Text; |
txt = editor.FindControl("txtEmail") as TextBox; |
email = txt.Text; |
Presenter.UpdateUser(uid, fn, ln, addr, city, st, zip, unm, email); |
RadGrid grid = e.Item.Parent as RadGrid; |
grid.Rebind(); |
rgAction.Rebind(); |
break; |
case "Cancel": |
default: |
break; |
} |
} |