| using System; |
| using System.Collections.Generic; |
| using System.Linq; |
| using System.Web; |
| using System.Web.UI; |
| using System.Web.UI.WebControls; |
| using Telerik.Web.UI; |
| using System.Collections; |
| using System.Configuration; |
| using System.Data; |
| using System.Web.Security; |
| using System.Text; |
| using System.Data.SqlClient; |
| using System.Web.UI.WebControls.WebParts; |
| using System.Web.UI.HtmlControls; |
| using System.Drawing; |
| public partial class _Default : System.Web.UI.Page |
| { |
| protected void Page_Load(object sender, System.EventArgs e) |
| { |
| } |
| protected override void OnLoad(EventArgs e) |
| { |
| if (!Page.IsPostBack) |
| { |
| GetDataFromSession(); |
| } |
| else |
| { |
| GetDataFromSession(); |
| } |
| } |
| private void GetDataFromSession() |
| { |
| DataTable dtTable = new DataTable(); |
| string conn = ConfigurationManager.ConnectionStrings["SecurityConnectionString"].ToString(); |
| SqlDataAdapter sqladp = new SqlDataAdapter(); |
| SqlConnection sqlconn = new SqlConnection(conn); |
| sqlconn.Open(); |
| try |
| { |
| string selectQuery = "SELECT [UserID], [Username] FROM [Users] ORDER BY [Username]"; |
| sqladp.SelectCommand = new SqlCommand(selectQuery, sqlconn); |
| sqladp.Fill(dtTable); |
| RadGrid1.DataSource = dtTable; |
| RadGrid1.DataBind(); |
| } |
| finally |
| { |
| sqlconn.Close(); |
| } |
| } |
| protected void RadGrid1_PageIndexChanged(object source, Telerik.Web.UI.GridPageChangedEventArgs e) |
| { |
| RadGrid1.DataBind(); |
| } |
| protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e) |
| { |
| if (e.CommandName == RadGrid.PerformInsertCommandName) |
| { |
| } |
| else if (e.CommandName == RadGrid.UpdateCommandName) |
| { |
| } |
| else if (e.CommandName == RadGrid.DeleteCommandName) |
| { |
| } |
| else if (e.CommandName == RadGrid.EditCommandName) |
| { |
| } |
| } |
| protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) |
| { |
| if ((e.Item is GridEditFormItem) && (e.Item.IsInEditMode)) |
| { |
| Session.Add("UserID", e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["UserID"].ToString()); |
| GridEditCommandColumn editColumn = (GridEditCommandColumn)RadGrid1.MasterTableView.GetColumn("EditCommandColumn"); |
| GridEditableItem item = (GridEditableItem)e.Item; |
| RadGrid Roles = (RadGrid)item.FindControl("RadGrid2"); |
| DataTable dtTable2 = new DataTable(); |
| string conn2 = ConfigurationManager.ConnectionStrings["SecurityConnectionString"].ToString(); |
| SqlDataAdapter sqladp2 = new SqlDataAdapter(); |
| SqlConnection sqlconn2 = new SqlConnection(conn2); |
| sqlconn2.Open(); |
| try |
| { |
| string selectQuery2 = "SELECT [RoleID],[Rolename] FROM [vw_UsersinRoles] WHERE [UserID] = " + Session["UserID"] + " ORDER BY [Username]"; |
| sqladp2.SelectCommand = new SqlCommand(selectQuery2, sqlconn2); |
| sqladp2.Fill(dtTable2); |
| } |
| finally |
| { |
| sqlconn2.Close(); |
| } |
| Roles.DataSource = dtTable2; |
| Roles.DataBind(); |
| Roles.Visible = true; |
| } |
| } |
| protected void RadGrid2_ItemDataBound(object sender, GridItemEventArgs e) |
| { |
| if ((e.Item is GridEditFormItem) && (e.Item.IsInEditMode)) |
| { |
| Session.Add("RoleID", e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["RoleID"].ToString()); |
| GridEditableItem item2 = (GridEditableItem)e.Item; |
| RadGrid Roles2 = (RadGrid)item2.FindControl("RadGrid3"); |
| GridEditCommandColumn editColumn2 = (GridEditCommandColumn)Roles2.MasterTableView.GetColumn("EditCommandColumn"); |
| DataTable dtTable2 = new DataTable(); |
| string conn2 = ConfigurationManager.ConnectionStrings["SecurityConnectionString"].ToString(); |
| SqlDataAdapter sqladp2 = new SqlDataAdapter(); |
| SqlConnection sqlconn2 = new SqlConnection(conn2); |
| sqlconn2.Open(); |
| try |
| { |
| string selectQuery2 = "SELECT [ClassID], [Classname] FROM [vw_UsersRolesClassesFormsCombined] WHERE [UserID] = " + Session["UserID"] + " ORDER BY [Username]"; |
| sqladp2.SelectCommand = new SqlCommand(selectQuery2, sqlconn2); |
| sqladp2.Fill(dtTable2); |
| } |
| finally |
| { |
| sqlconn2.Close(); |
| } |
| Roles2.DataSource = dtTable2; |
| Roles2.DataBind(); |
| Roles2.Visible = true; |
| } |
| } |
| protected void RadGrid3_ItemDataBound(object sender, GridItemEventArgs e) |
| { |
| if ((e.Item is GridEditFormItem) && (e.Item.IsInEditMode)) |
| { |
| Session.Add("ClassID", e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["ClassID"].ToString()); |
| GridEditableItem item3 = (GridEditableItem)e.Item; |
| RadGrid Roles3 = (RadGrid)item3.FindControl("RadGrid4"); |
| GridEditCommandColumn editColumn3 = (GridEditCommandColumn)Roles3.MasterTableView.GetColumn("EditCommandColumn"); |
| DataTable dtTable2 = new DataTable(); |
| string conn2 = ConfigurationManager.ConnectionStrings["SecurityConnectionString"].ToString(); |
| SqlDataAdapter sqladp2 = new SqlDataAdapter(); |
| SqlConnection sqlconn2 = new SqlConnection(conn2); |
| sqlconn2.Open(); |
| try |
| { |
| string selectQuery2 = "SELECT [FormID], [Formname] FROM [vw_UsersRolesClassesFormsCombined] WHERE [UserID] = " + Session["UserID"] + " AND [ClassID] = " + Session["ClassID"] + "ORDER BY [Username]"; |
| sqladp2.SelectCommand = new SqlCommand(selectQuery2, sqlconn2); |
| sqladp2.Fill(dtTable2); |
| } |
| finally |
| { |
| sqlconn2.Close(); |
| } |
| Roles3.DataSource = dtTable2; |
| Roles3.DataBind(); |
| Roles3.Visible = true; |
| } |
| } |
| protected void RadGrid3_ItemCommand(object source, GridCommandEventArgs e) |
| { |
| if (e.CommandName == RadGrid.PerformInsertCommandName) |
| { |
| } |
| else if (e.CommandName == RadGrid.UpdateCommandName) |
| { |
| } |
| else if (e.CommandName == RadGrid.DeleteCommandName) |
| { |
| } |
| else if (e.CommandName == RadGrid.EditCommandName) |
| { |
| } |
| } |
| protected void RadGrid4_ItemDataBound(object sender, GridItemEventArgs e) |
| { |
| if ((e.Item is GridEditFormItem) && (e.Item.IsInEditMode)) |
| { |
| Session.Add("FormID", e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["FormID"].ToString()); |
| GridEditableItem item3 = (GridEditableItem)e.Item; |
| RadGrid Roles3 = (RadGrid)item3.FindControl("RadGrid4"); |
| GridEditCommandColumn editColumn3 = (GridEditCommandColumn)Roles3.MasterTableView.GetColumn("EditCommandColumn"); |
| DataTable dtTable2 = new DataTable(); |
| string conn2 = ConfigurationManager.ConnectionStrings["SecurityConnectionString"].ToString(); |
| SqlDataAdapter sqladp2 = new SqlDataAdapter(); |
| SqlConnection sqlconn2 = new SqlConnection(conn2); |
| sqlconn2.Open(); |
| try |
| { |
| string selectQuery2 = "SELECT [FormID], [Formname] FROM [vw_UsersRolesClassesFormsCombined] WHERE [UserID] = " + Session["UserID"] + " AND [ClassID] = " + Session["ClassID"] + "ORDER BY [Username]"; |
| sqladp2.SelectCommand = new SqlCommand(selectQuery2, sqlconn2); |
| sqladp2.Fill(dtTable2); |
| } |
| finally |
| { |
| sqlconn2.Close(); |
| } |
| Roles3.DataSource = dtTable2; |
| Roles3.DataBind(); |
| Roles3.Visible = true; |
| } |
| } |
| } |
| <form id="form1" runat="server"> |
| <telerik:RadGrid ID="RadGrid1" runat="server" AllowFilteringByColumn="True" AllowPaging="True" |
| AllowSorting="True" GridLines="None" Width="600px" AutoGenerateColumns="false" |
| AllowAutomaticDeletes="True" AllowAutomaticInserts="True" AllowAutomaticUpdates="True" |
| GroupingSettings-CaseSensitive="false" PageSize="20" EnableLinqExpressions="False" |
| OnItemDataBound="RadGrid1_ItemDataBound" ShowStatusBar="True" OnPageIndexChanged="RadGrid1_PageIndexChanged" |
| OnItemCommand="RadGrid1_ItemCommand"> |
| <MasterTableView ShowFooter="False" CommandItemSettings-AddNewRecordText="Add New User" |
| CommandItemDisplay="TopAndBottom" DataKeyNames="UserID"> |
| <CommandItemSettings AddNewRecordText="Add New User"></CommandItemSettings> |
| <RowIndicatorColumn> |
| <HeaderStyle Width="20px"></HeaderStyle> |
| </RowIndicatorColumn> |
| <ExpandCollapseColumn> |
| <HeaderStyle Width="20px"></HeaderStyle> |
| </ExpandCollapseColumn> |
| <Columns> |
| <telerik:GridEditCommandColumn HeaderStyle-Width="15px" EditText="View / Edit"> |
| <HeaderStyle Width="15px"></HeaderStyle> |
| </telerik:GridEditCommandColumn> |
| <telerik:GridTemplateColumn UniqueName="DeleteColumn" ItemStyle-Width="16px" AllowFiltering="false"> |
| <HeaderStyle Width="16px" /> |
| <ItemTemplate> |
| <asp:ImageButton ID="imgbtnDelete" Width="14px" ToolTip="Delete Contact" runat="server" |
| CommandName="Delete" ImageUrl="~/images/recycle.jpg" OnClientClick="javascript:if(!confirm('This action will delete the selected contact. Are you sure?')){return false;}" /> |
| </ItemTemplate> |
| <ItemStyle Width="16px"></ItemStyle> |
| </telerik:GridTemplateColumn> |
| <telerik:GridBoundColumn DataField="Username" HeaderText="Username" SortExpression="Username" |
| UniqueName="Username"> |
| </telerik:GridBoundColumn> |
| </Columns> |
| <EditFormSettings CaptionFormatString="Edit details for User {0}" EditFormType="Template"> |
| <EditColumn UniqueName="EditCommandColumn1"> |
| </EditColumn> |
| <FormTemplate> |
| <table> |
| <tr> |
| <td> |
| <telerik:RadGrid ID="RadGrid2" runat="server" AllowPaging="True" |
| GridLines="None" AutoGenerateColumns="false" AllowAutomaticDeletes="True" OnItemDataBound="RadGrid2_ItemDataBound" |
| AllowAutomaticInserts="True" AllowAutomaticUpdates="True" PageSize="20" Width="500px" |
| ShowStatusBar="True"> |
| <MasterTableView ShowFooter="False" CommandItemSettings-AddNewRecordText="Add New Role" |
| CommandItemDisplay="TopAndBottom" DataKeyNames="RoleID"> |
| <CommandItemSettings AddNewRecordText="Add New Role"></CommandItemSettings> |
| <RowIndicatorColumn> |
| <HeaderStyle Width="20px"></HeaderStyle> |
| </RowIndicatorColumn> |
| <ExpandCollapseColumn> |
| <HeaderStyle Width="20px"></HeaderStyle> |
| </ExpandCollapseColumn> |
| <Columns> |
| <telerik:GridEditCommandColumn HeaderStyle-Width="15px" EditText="View / Edit"> |
| <HeaderStyle Width="15px"></HeaderStyle> |
| </telerik:GridEditCommandColumn> |
| <telerik:GridTemplateColumn UniqueName="DeleteColumn2" ItemStyle-Width="16px" AllowFiltering="false"> |
| <HeaderStyle Width="16px" /> |
| <ItemTemplate> |
| <asp:ImageButton ID="imgbtnDelete2" Width="14px" ToolTip="Delete Contact" runat="server" |
| CommandName="Delete" ImageUrl="~/images/recycle.jpg" OnClientClick="javascript:if(!confirm('This action will delete the selected contact. Are you sure?')){return false;}" /> |
| </ItemTemplate> |
| <ItemStyle Width="16px"></ItemStyle> |
| </telerik:GridTemplateColumn> |
| <telerik:GridBoundColumn DataField="Rolename" HeaderText="Rolename" SortExpression="Rolename" |
| UniqueName="Rolename"> |
| </telerik:GridBoundColumn> |
| </Columns> |
| <EditFormSettings CaptionFormatString="Edit details for User {0}" EditFormType="Template"> |
| <EditColumn UniqueName="EditCommandColumn2"> |
| </EditColumn> |
| <FormTemplate> |
| <table> |
| <tr> |
| <td> |
| <telerik:RadGrid ID="RadGrid3" runat="server" AllowPaging="True" |
| GridLines="None" AutoGenerateColumns="false" AllowAutomaticDeletes="True" OnItemDataBound="RadGrid3_ItemDataBound" OnItemCommand="RadGrid3_ItemCommand" |
| AllowAutomaticInserts="True" AllowAutomaticUpdates="True" GroupingSettings-CaseSensitive="false" |
| PageSize="20" EnableLinqExpressions="False" Width="400px" ShowStatusBar="True"> |
| <MasterTableView ShowFooter="False" CommandItemSettings-AddNewRecordText="Add New Class" |
| CommandItemDisplay="TopAndBottom" > |
| <CommandItemSettings AddNewRecordText="Add New Class"></CommandItemSettings> |
| <RowIndicatorColumn> |
| <HeaderStyle Width="20px"></HeaderStyle> |
| </RowIndicatorColumn> |
| <ExpandCollapseColumn> |
| <HeaderStyle Width="20px"></HeaderStyle> |
| </ExpandCollapseColumn> |
| <Columns> |
| <telerik:GridEditCommandColumn HeaderStyle-Width="15px" EditText="View / Edit"> |
| <HeaderStyle Width="15px"></HeaderStyle> |
| </telerik:GridEditCommandColumn> |
| <telerik:GridTemplateColumn UniqueName="DeleteColumn3" ItemStyle-Width="16px" AllowFiltering="false"> |
| <HeaderStyle Width="16px" /> |
| <ItemTemplate> |
| <asp:ImageButton ID="imgbtnDelete3" Width="14px" ToolTip="Delete Contact" runat="server" |
| CommandName="Delete" ImageUrl="~/images/recycle.jpg" OnClientClick="javascript:if(!confirm('This action will delete the selected contact. Are you sure?')){return false;}" /> |
| </ItemTemplate> |
| <ItemStyle Width="16px"></ItemStyle> |
| </telerik:GridTemplateColumn> |
| <telerik:GridBoundColumn DataField="Classname" HeaderText="Classname" SortExpression="Classname" |
| UniqueName="Classname"> |
| </telerik:GridBoundColumn> |
| </Columns> |
| <EditFormSettings CaptionFormatString="Edit details for User {0}" EditFormType="Template"> |
| <EditColumn UniqueName="EditCommandColumn3"> |
| </EditColumn> |
| <FormTemplate> |
| <table> |
| <tr> |
| <td> |
| <telerik:RadGrid ID="RadGrid4" runat="server" AllowFilteringByColumn="True" AllowPaging="True" |
| GridLines="None" AutoGenerateColumns="false" AllowAutomaticDeletes="True" OnItemDataBound="RadGrid4_ItemDataBound" |
| AllowAutomaticInserts="True" AllowAutomaticUpdates="True" GroupingSettings-CaseSensitive="false" |
| PageSize="20" EnableLinqExpressions="False" Width="300px" ShowStatusBar="True"> |
| <MasterTableView ShowFooter="False" CommandItemSettings-AddNewRecordText="Add New Form" |
| CommandItemDisplay="TopAndBottom" DataKeyNames="FormID"> |
| <CommandItemSettings AddNewRecordText="Add New Form"></CommandItemSettings> |
| <RowIndicatorColumn> |
| <HeaderStyle Width="20px"></HeaderStyle> |
| </RowIndicatorColumn> |
| <ExpandCollapseColumn> |
| <HeaderStyle Width="20px"></HeaderStyle> |
| </ExpandCollapseColumn> |
| <Columns> |
| <telerik:GridTemplateColumn UniqueName="DeleteColumn4" ItemStyle-Width="16px" AllowFiltering="false"> |
| <HeaderStyle Width="16px" /> |
| <ItemTemplate> |
| <asp:ImageButton ID="imgbtnDelete4" Width="14px" ToolTip="Delete Contact" runat="server" |
| CommandName="Delete" ImageUrl="~/images/recycle.jpg" OnClientClick="javascript:if(!confirm('This action will delete the selected contact. Are you sure?')){return false;}" /> |
| </ItemTemplate> |
| <ItemStyle Width="16px"></ItemStyle> |
| </telerik:GridTemplateColumn> |
| <telerik:GridBoundColumn DataField="Formname" HeaderText="Formname" SortExpression="Formname" |
| UniqueName="Formname"> |
| </telerik:GridBoundColumn> |
| </Columns> |
| <NoRecordsTemplate> |
| No Records</NoRecordsTemplate> |
| </MasterTableView> |
| </telerik:RadGrid> |
| </td> |
| </tr> |
| <tr> |
| <td> |
| <asp:Button ID="btnUpdate3" Text='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Update" %>' |
| runat="server" CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>'> |
| </asp:Button> |
| <asp:Button ID="btnCancel3" Text="Cancel" runat="server" CausesValidation="False" |
| CommandName="Cancel"></asp:Button> |
| </td> |
| </tr> |
| <table> |
| </FormTemplate> |
| </EditFormSettings> |
| <NoRecordsTemplate> |
| No Records</NoRecordsTemplate> |
| </MasterTableView> |
| </telerik:RadGrid> |
| </td> |
| </tr> |
| <tr> |
| <td> |
| <asp:Button ID="btnUpdate2" Text='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Update" %>' |
| runat="server" CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>'> |
| </asp:Button> |
| <asp:Button ID="btnCancel2" Text="Cancel" runat="server" CausesValidation="False" |
| CommandName="Cancel"></asp:Button> |
| </td> |
| </tr> |
| <table> |
| </FormTemplate> |
| </EditFormSettings> |
| <NoRecordsTemplate> |
| No Records</NoRecordsTemplate> |
| </MasterTableView> |
| </telerik:RadGrid> |
| </td> |
| </tr> |
| <tr> |
| <td> |
| <asp:Button ID="btnUpdate" Text='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Update" %>' |
| runat="server" CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>'> |
| </asp:Button> |
| <asp:Button ID="btnCancel" Text="Cancel" runat="server" CausesValidation="False" |
| CommandName="Cancel"></asp:Button> |
| </td> |
| </tr> |
| <table> |
| </FormTemplate> |
| </EditFormSettings> |
| <NoRecordsTemplate> |
| No Records</NoRecordsTemplate> |
| </MasterTableView> |
| <GroupingSettings CaseSensitive="False"></GroupingSettings> |
| </telerik:RadGrid> |
| <asp:ScriptManager ID="ScriptManager1" runat="server"> |
| </asp:ScriptManager> |
| </form> |
RadGrid1 fires perfect, RadGrid2 fires perfect, and RadGrid3 loads but when editing the command never fires. I set my break point and only hits when loads but not when hit the view / edit. Thanks in advance.