
| /// <summary> |
| /// Fires when an item was created. |
| /// </summary> |
| /// <param name="sender"></param> |
| /// <param name="e"></param> |
| void _RadGridOnPage_ItemCreated(object sender, GridItemEventArgs e) |
| { |
| if (e.Item.GetType() == typeof(GridEditFormItem)) |
| { |
| SetEditFormCssClass(e.Item.Controls); |
| } |
| //create the custom active col image dropdown filter |
| if (e.Item.GetType() == typeof(GridFilteringItem)) |
| { |
| //create custom filtering dropdown for active col here. |
| GridFilteringItem filteringItem = (e.Item as GridFilteringItem); |
| try |
| { |
| if (filteringItem["clActive"] == null) return; //exit if the active column does not exist |
| } |
| catch |
| { |
| return; //if the col doesnt exist exit. |
| } |
| //append the filtering cbo to the filter header of the col in the grid. |
| filteringItem["clActive"].Controls.Add(CreateActiveColFilterCbo()); //append the new filtering cbo to the filter row |
| if (HttpContext.Current.Session["activeFilterCellClientId"] != null) |
| { |
| HttpContext.Current.Session.Add("activeFilterCellClientId", filteringItem["clActive"].ClientID); |
| } |
| } |
| } |
| /// <summary> |
| /// creates the custom filtering cbo with the tick and cross images. |
| /// </summar |
| private RadComboBox CreateActiveColFilterCbo() |
| { |
| RadComboBox cbo = new RadComboBox(); |
| //create the items to hold the images |
| RadComboBoxItem active = new RadComboBoxItem("Active"); |
| RadComboBoxItem inactive = new RadComboBoxItem("Inactive"); |
| RadComboBoxItem nofilter = new RadComboBoxItem("No Filter"); |
| //create and append the images to the items |
| HtmlImage tick = new HtmlImage(); |
| tick.Src = HttpContext.Current.Request.ApplicationPath + "/images/admin-tick-whitebg.GIF"; |
| HtmlImage cross = new HtmlImage(); |
| cross.Src = HttpContext.Current.Request.ApplicationPath + "/images/admin-cross-whitebg.GIF"; |
| active.Controls.Add(tick); |
| inactive.Controls.Add(cross); |
| //add the items containing the images to the ctl |
| cbo.Items.Add(active); |
| cbo.Items.Add(inactive); |
| cbo.Items.Add(nofilter); |
| cbo.ID = "activeFilterCbo"; |
| cbo.Width = new Unit(65, UnitType.Pixel); |
| cbo.Skin = "WebBlue"; |
| cbo.AutoPostBack = true; |
| cbo.SelectedIndexChanged += new RadComboBoxSelectedIndexChangedEventHandler(cbo_SelectedIndexChanged); |
| return cbo; |
| } |
| public void cbo_SelectedIndexChanged(object sender, EventArgs e) |
| { |
| _RadGridOnPage.MasterTableView.Rebind(); |
| } |
| <radG:RadGrid ID="RadGrid1" |
| runat="server"> |
| <MasterTableView > |
| <Columns> |
| <radG:GridTemplateColumn UniqueName="clActive" AllowFiltering=false> |
| <ItemTemplate> |
| <asp:Image ID="imgActive" |
| runat="server" /> |
| <asp:Label ID="lblActive" |
| runat="server" |
| Text='<%# DataBinder.Eval(Container,"DataItem." + comQuest.Common.Constants.Columns.USR_Active) %>' |
| style="display: none"></asp:Label> |
| </ItemTemplate> |
| </radG:GridTemplateColumn> |
| </Columns> |
| <ExpandCollapseColumn Visible="False" Resizable="False"> |
| <HeaderStyle Width="20px" /> |
| </ExpandCollapseColumn> |
| <RowIndicatorColumn Visible="False"> |
| <HeaderStyle Width="20px" /> |
| </RowIndicatorColumn> |
| </MasterTableView> |
| <ExportSettings> |
| <Pdf PageBottomMargin="" PageFooterMargin="" PageHeaderMargin="" PageHeight="11in" |
| PageLeftMargin="" PageRightMargin="" PageTopMargin="" PageWidth="8.5in" /> |
| </ExportSettings> |
| </radG:RadGrid> |
| /// <summary> |
| /// Sets up the databound cols and other grid properties |
| /// </summary> |
| public void CreateGrid(bool enableAjax, Dictionary<string, bool> ColumnsFilterStatus) |
| { |
| //create the grid |
| _RadGridOnPage.CssClass = "RadGrid"; |
| //_RadGridOnPage.PageSize = 5; |
| _RadGridOnPage.AllowPaging = true; |
| _RadGridOnPage.AutoGenerateColumns = false; |
| _RadGridOnPage.Visible = true; |
| _RadGridOnPage.Width = new Unit(98, UnitType.Percentage); |
| _RadGridOnPage.MasterTableView.EditMode = GridEditMode.EditForms; |
| _RadGridOnPage.Skin = "WebBlue"; |
| _RadGridOnPage.MasterTableView.PageSize = 20; |
| _RadGridOnPage.MasterTableView.AutoGenerateColumns = false; |
| _RadGridOnPage.HeaderStyle.Font.Size = new FontUnit("8pt"); |
| if (enableAjax) |
| { |
| _RadGridOnPage.LoadingTemplateTransparency = 50; |
| _RadGridOnPage.ShowGroupPanel = true; |
| _RadGridOnPage.ClientSettings.AllowDragToGroup = true; |
| _RadGridOnPage.AllowFilteringByColumn = true; |
| _RadGridOnPage.EnableAJAX = true; |
| _RadGridOnPage.EnableAJAXLoadingTemplate = true; |
| } |
| _RadGridOnPage.AllowSorting = true; |
| //_RadGridOnPage.AllowFilteringByColumn = true; |
| _RadGridOnPage.PagerStyle.CssClass = "gridpager"; |
| _RadGridOnPage.PagerStyle.Mode = GridPagerMode.NumericPages; |
| //setup the add new entry at the top of the grid |
| if (_EnableRecordAdd) |
| { |
| _RadGridOnPage.MasterTableView.CommandItemSettings.AddNewRecordText = _AddNewRecordText; |
| _RadGridOnPage.MasterTableView.CommandItemDisplay = GridCommandItemDisplay.Top; |
| } |
| else |
| { |
| _RadGridOnPage.MasterTableView.CommandItemDisplay = GridCommandItemDisplay.None; |
| } |
| // Set data source. |
| _RadGridOnPage.DataSource = _MainDataSet; |
| _RadGridOnPage.DataMember = _DataTableNameAsDatasource; // The datatable to be the datasource |
| //add grid cols |
| AddGridCols(_RadGridOnPage.MasterTableView, ColumnsFilterStatus); |
| if (EnableSimpleDetailView) |
| { |
| if (_RadGridOnPage.MasterTableView.DetailTables.Count > 0) |
| { |
| AddGridCols(_RadGridOnPage.MasterTableView.DetailTables[0], ColumnsFilterStatus); |
| } |
| } |
| _RadGridOnPage.DataSource = _MainDataSet; |
| _RadGridOnPage.DataBind(); |
| // Add the edit column |
| if (_EnableRecordEdit) |
| { |
| GridEditCommandColumn editCol = new GridEditCommandColumn(); |
| _RadGridOnPage.MasterTableView.Columns.Add(editCol); |
| editCol.EditText = comQuest.Resources.Resources.GetMessage("RES_Grid_EditColumnEditText"); |
| editCol.OrderIndex = _MainDataSet.Tables[_DataTableNameAsDatasource].Columns.Count + 2; |
| } |
| // Add the delete column |
| if (_EnableRecordDelete) |
| { |
| GridButtonColumn butCol = new GridButtonColumn(); |
| _RadGridOnPage.MasterTableView.Columns.Add(butCol); |
| butCol.CommandName = "Delete"; |
| butCol.Text = comQuest.Resources.Resources.GetMessage("RES_Grid_DeleteColumnDeleteText"); |
| butCol.UniqueName = "DeleteColumn"; |
| butCol.OrderIndex = _MainDataSet.Tables[_DataTableNameAsDatasource].Columns.Count + 3; |
| butCol.ConfirmText = comQuest.Resources.Resources.GetMessage("RES_GridDeleteConfirmationMessage"); |
| } |
| //format design time columns |
| FormatActiveColumn(_RadGridOnPage.MasterTableView); |
| if (EnableSimpleDetailView) |
| { |
| if (_RadGridOnPage.MasterTableView.DetailTables.Count > 0) |
| { |
| FormatActiveColumn(_RadGridOnPage.MasterTableView.DetailTables[0]); |
| } |
| } |
| // Set colours |
| SetColours(); |
| // Prevent from jumping to last page after insert |
| _RadGridOnPage.ItemCommand += new GridCommandEventHandler(_RadGridOnPage_ItemCommand); |
| } |
| void ToDoOnNew() |
| { |
| // This event handlers needs to build every time. On load and postback. |
| _RadGridOnPage.NeedDataSource += new GridNeedDataSourceEventHandler(_RadGridOnPage_NeedDataSource); |
| _RadGridOnPage.ItemDataBound += new GridItemEventHandler(_RadGridOnPage_ItemDataBound); |
| _RadGridOnPage.UpdateCommand += new GridCommandEventHandler(_RadGridOnPage_UpdateCommand); |
| _RadGridOnPage.InsertCommand += new GridCommandEventHandler(_RadGridOnPage_InsertCommand); |
| _RadGridOnPage.DeleteCommand += new GridCommandEventHandler(_RadGridOnPage_DeleteCommand); |
| _RadGridOnPage.DetailTableDataBind += new GridDetailTableDataBindEventHandler(_RadGridOnPage_DetailTableDataBind); |
| _RadGridOnPage.ItemCreated += new GridItemEventHandler(_RadGridOnPage_ItemCreated); |
| _RadGridOnPage.Load += new EventHandler(_RadGridOnPage_Load); |
| // Make sure all the lists are new and not null. |
| if (_ColumnsToExclude == null) _ColumnsToExclude = new List<string>(); |
| if (_DropdownColumns == null) _DropdownColumns = new List<RadGridHelperDropdownColumn>(); |
| if (_GuidBeingEdited == null) _GuidBeingEdited = new Dictionary<string, Guid>(); |
| if (_ReadOnlyColumnNames == null) _ReadOnlyColumnNames = new List<string>(); |
| } |
im
dtType As New DataTable
Dim daType As New SqlDataAdapter
Dim sqlCmd As New SqlCommand("spSelect", x.getConn)
sqlCmd.CommandType = CommandType.StoredProcedure
sqlCmd.Parameters.Add(New SqlParameter("@search", SqlDbType.NVarChar, 10)).Value = "All"
sqlCmd.Parameters.Add(New SqlParameter("@Type", SqlDbType.NVarChar, 10)).Value = "All"
daType.SelectCommand = sqlCmd
daType.Fill(dtCourse)
gridType.DataSource = dtType
gridType.DataBind()
This RADgrid has sorting enabled. I set a breakpoint at the page load event.
When the page was loading, yes indeed it hit the breakpoint and i press F11 to step into the code. But the strange thing is that it also step into this code:
<
ItemTemplate>
<a href="#" onclick="openRadWindow('<%#DataBinder.Eval(Container.DataItem,"TypeCode")%>'); return false;">Update</a>
</ItemTemplate>
several times. Same thing would happen every time i did a sort. Why is that so and how to make sure it does not step into this: <a href="#" onclick="openRadWindow('<%#DataBinder.Eval(Container.DataItem,"TypeCode")%>'); return false;">Update</a>
Thanks