Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
115 views
Hello,

         I am using schedular in my application.
         I have kept WeekView As Default & it shows up all 24 hours duration in Schedular.

         Now what i want is, if the difference of the Appointment START & END is more than 8  Hours for a particular appointment,
         then that Appointment should be displayed at the TOP as a Whole Day Appointment.


          Please reply,


Thanks,
Kunal Patel
Peter
Telerik team
 answered on 24 Feb 2010
1 answer
87 views
It has so many examples posted to save dynamic docks to DB and retrieve from DB. I couldn't figure out why the dock state are always empty when I added multi docks once. If I only add one dock per time, it works.

My situation is that all the user controls will be added to the docks together (once)  when user first goes to Dock widget page. Then user can drag, close, drop... etc  docks.User's dock state will save to DB after user click "Save" button. Before User click save button,  I saved the dockstate to the viewstate variable.The issue is that when I retrieve dockstate from the viewstate varible on ButtonSave_Click event, the viewstate variable is always nothing.


Can any one help me out?

Pls: it is the first time for me to post the question. not sure what is the best way to post codes since It took me 10 minutes to remove the extra empty space even I used the "Format Code Block". any suggestion?

My codes:

 

 

Private ReadOnly Property CurrentDockStates() As List(Of DockState)   
 Get   
 Dim dockStatesFromDB As String   
 if Not ViewState("UserDockStatesFromDB") Is Nothing AndAlso CType(ViewState("UserDockStatesFromDB"), String) <> String.Empty Then   
     dockStatesFromDB = CType(ViewState("UserDockStatesFromDB"), String)   
 End If   
 Dim _currentDockStates As New List(Of DockState)()  
 If dockStatesFromDB <> String.Empty Then   
        Dim stringStates As String() = dockStatesFromDB.Split("|")   
        For Each stringState As String In stringStates   
                   If stringState.Trim() <> String.Empty Then   
                      _currentDockStates.Add(DockState.Deserialize(stringState))   
                   End If 
       Next   
End If   
 
Return _currentDockStates   
End Get   
End Property 
 
 
Protected Sub Page_Init(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Init   
If Not Page.IsPostBack Then   
  loadData()  
  ViewState("UserDockStatesFromDB") = GetUserDockState()   
 End If   
 'Recreate the docks in order to ensure their proper operation  
Dim i As Integer = 0   
While i < CurrentDockStates.Count   
    If CurrentDockStates(i).Closed = False Then   
      Dim dock As RadDock = CreateRadDockFromState(CurrentDockStates(i))   
      RadDockLayout1.Controls.Add(dock)  
 
     'We want to save the dock state every time a dock is moved.    
      CreateSaveStateTrigger(dock)  
      'Load the selected widget   
      LoadWidget(dock)  
End If   
System.Math.Max(System.Threading.Interlocked.Increment(i), i - 1)  
End While   
End Sub   
   
 
Private Function GetUserDockState() As String      
 Dim strUserDockStatesFromDB As String      
 Dim ds As DataSet      
 Dim intViewCategotyID As Integer = -1      
 Dim dr As DataRow      
 Dim dt As DataTable      
 Dim objBS As New  BusinessServices.DockView       
objBS.SystemUserID = SystemUserID       
If Not Me.drpDockViewCategoty.SelectedItem Is Nothing Then      
  intViewCategotyID = Me.drpDockViewCategoty.SelectedValue          
End If      
       
ds = objBS.GetSystemUserDockState(intViewCategotyID)       
CommonMethods.SetFormDataSet(GS.tblSystemUserDockState, FormData)       
If Not ds.Tables(GS.tblSystemUserDockState) Is Nothing Then        
dt = ds.Tables(GS.tblSystemUserDockState)      
If Not dt.Rows Is Nothing AndAlso dt.Rows.Count > 0 Then    
With ds.Tables(GS.tblSystemUserDockState).Rows(0)   
  strUserDockStatesFromDB = .Item("DockState")      
  CurUserDockStateID = GS.Null2Zero(.Item("SystemDockStateID"))      
  CurViewCategoryID = GS.Null2Zero(.Item("DockViewCategoryID"))     
End With      
End If       
End If       
    
If strUserDockStatesFromDB = String.Empty Then       
'reload all the default control        
CreateDefaultRadDock()       
End If      
    
Return strUserDockStatesFromDB        
End Function        
    
    
    
Private Sub loadData()     
'load View Category    
End Sub      
      
Private Function CreateRadDockFromState(ByVal state As DockState) As RadDock      
Dim dock As New RadDock()      
 dock.DockMode = DockMode.Docked      
dock.ID = String.Format("RadDock{0}", state.UniqueName)       
dock.ApplyState(state)      
dock.EnableAnimation = True    
dock.Commands.Add(New DockCloseCommand())  
dock.Commands.Add(New DockExpandCollapseCommand())      
      
Return dock      
End Function    
     
Private Function CreateRadDock(ByVal strTitle As String) As RadDock      
   Dim docksCount As Integer = CurrentDockStates.Count      
   Dim dock As New RadDock()      
   dock.DockMode = DockMode.Docked      
   dock.UniqueName = Guid.NewGuid().ToString()     
   dock.ID = String.Format("RadDock{0}", dock.UniqueName)      
   dock.Title = strTitle     
   'dock.EnableAnimation = True      
   dock.Text =String.Format("Added at {0}", DateTime.Now)      
   dock.Width = Unit.Pixel(100)     
   dock.BorderWidth = Unit.Pixel(2)     
   dock.BorderColor = Color.LightGray     
   dock.Commands.Add(New DockCloseCommand())      
      dock.Commands.Add(New DockExpandCollapseCommand())      
  dock.CommandsAutoPostBack = True      
       
Return dock      
      
End Function      
 'when user first time load Dock layout, it will load all the control to three radzone      
 Private Sub CreateDefaultRadDock()     
 Dim index As Integer      
 Dim DockList As New ArrayList()      
 Dim intCount As Integer = 0      
  Dim intReminder As Integer      
  Dim dock As RadDock      
  If Not Me.chkDockList.Items Is Nothing Then      
  intCount = Me.chkDockList.Items.Count      
  End If      
      
      
For index = 0 To intCount - 1     
dock = CreateRadDock(chkDockList.Items(index).Text)    
intReminder = index Mod 3      
 Select Case intReminder      
   Case 0      
   RadDockZone1.Controls.Add(dock)     
  Case 1      
 RadDockZone2.Controls.Add(dock)     
  Case 2      
  RadDockZone3.Controls.Add(dock)     
  End Select      
   Me.chkDockList.Items(index).Selected = True      
  'We want to save the dock state every time a dock is moved.      
  CreateSaveStateTrigger(dock)     
  'Load the selected widget      
   dock.Tag = chkDockList.Items(index).Value     
    
LoadWidget(dock)     
Next index      
  End Sub    
 
Private  Sub CreateSaveStateTrigger(ByVal dock As RadDock)      
        
'Ensure that the RadDock control will initiate postback      
' when its position changes on the client or any of the commands is clicked.      
 'Using the trigger we will "ajaxify" that postback.      
  dock.AutoPostBack = True      
   dock.CommandsAutoPostBack = True      
      
Dim saveStateTrigger As New AsyncPostBackTrigger()      
    saveStateTrigger.ControlID = dock.ID     
    
saveStateTrigger.EventName = "DockPositionChanged"      
    UpdatePanel1.Triggers.Add(saveStateTrigger)     
    
saveStateTrigger = New AsyncPostBackTrigger()      
saveStateTrigger.ControlID = dock.ID     
saveStateTrigger.EventName =  "Command"      
 
    
UpdatePanel1.Triggers.Add(saveStateTrigger)     
    
 
End Sub      
 
    
Private Sub LoadWidget(ByVal dock As RadDock)      
 
If String.IsNullOrEmpty(dock.Tag) Then      
 
Return      
 
End If      
 Dim widget As Control = LoadControl(dock.Tag)      
 
dock.ContentContainer.Controls.Add(widget)     
 
End Sub      
 
Protected Sub RadDockLayout1_LoadDockLayout(ByVal sender As Object, ByVal e As DockLayoutEventArgs) Handles RadDockLayout1.LoadDockLayout      
 
Try      
 
    
Dim serializedList As String      
      
 If Not ViewState("UserDockStatesFromDB") Is Nothing Then      
  serializedList = ViewState(     
    
"UserDockStatesFromDB")      
      
    
      
    
    
    
End If      
      
    
    
    
      
    
If serializedList <> Nothing Then      
      
    
    
    
      
    
Dim states As String() = serializedList.Split("|"c)      
      
    
      
    
    
    
Dim i As Integer = 0      
      
    
      
    
    
    
While i < states.Length      
      
    
      
    
    
    
Dim state As DockState = DockState.Deserialize(states(i))      
      
    
e.Positions(state.UniqueName) = state.DockZoneID     
    
e.Indices(state.UniqueName) = state.Index     
    
      
    
    
    
System.Math.Max(System.Threading.Interlocked.Increment(i), i - 1)      
 
End While      
 
    
End If      
   Catch ex As Exception      
 
End Try      
 End Sub    
 
Protected Sub RadDockLayout1_SaveDockLayout(ByVal sender As Object, ByVal e As DockLayoutEventArgs) Handles RadDockLayout1.SaveDockLayout      
      
 Dim stateList As List(Of DockState)=RadDockLayout1.GetRegisteredDocksState()      
 Dim serializedList As New StringBuilder()      
   Dim i As Integer = 0      
 While i < stateList.Count      
serializedList.Append(stateList(i).ToString())     
serializedList.Append("|")      
System.Math.Max(System.Threading.Interlocked.Increment(i), i - 1)     
 
End While      
   
    
Dim dockState As String = serializedList.ToString()      
  If dockState.Trim() <> String.Empty Then      
     
ViewState("UserDockStatesFromDB") = dockState      
      
  End If      
End Sub      
      
      
'+-------------------------------------------------------------------------------'| Method : ButtonSave_Click      
'| Purpose : save all the state when user click Save button      
'| Returns : Boolean    
'+-------------------------------------------------------------------------------  
Protected Sub ButtonSave_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnSave.Click      
 
Dim dockState As String      
  If Not ViewState("UserDockStatesFromDB") Is Nothing Then      
    dockState = ViewState("UserDockStatesFromDB")      
End If    
    
If GetControlData(dockState) Then      
 
SaveUserDockState(FormData)     
 
End If      
 End Sub      
      
    
    
    
    
 
Private
 Function GetUserDockState() As String   
 Dim strUserDockStatesFromDB As String   
 Dim ds As DataSet   
 Dim intViewCategotyID As Integer = -1   
 Dim dr As DataRow   
 Dim dt As DataTable   
 Dim objBS As New  BusinessServices.DockView   
 
objBS.SystemUserID = SystemUserID  
 
   
 
 
 
If Not Me.drpDockViewCategoty.SelectedItem Is Nothing Then   
   
 
   
 
   
 
 
 
   
   
 
         intViewCategotyID =   
 
 
 
Me.drpDockViewCategoty.SelectedValue   
   
 
   
 
 
 
End If   
   
 
   
 
   
 
 
 
   
   
 
ds = objBS.GetSystemUserDockState(intViewCategotyID)  
 
CommonMethods.SetFormDataSet(GS.tblSystemUserDockState, FormData)  
 
   
 
 
 
If Not ds.Tables(GS.tblSystemUserDockState) Is Nothing Then   
   
 
   
 
   
 
 
 
   
   
 
dt = ds.Tables(GS.tblSystemUserDockState)  
 
   
 
 
 
If Not dt.Rows Is Nothing AndAlso dt.Rows.Count > 0 Then   
   
 
   
 
   
 
 
 
   
   
 
   
 
 
 
With ds.Tables(GS.tblSystemUserDockState).Rows(0)   
   
 
      strUserDockStatesFromDB = .Item(  
 
 
 
"DockState")   
   
 
      CurUserDockStateID = GS.Null2Zero(.Item(  
 
 
 
"SystemDockStateID"))   
   
 
      CurViewCategoryID = GS.Null2Zero(.Item(  
 
 
 
"DockViewCategoryID"))   
   
 
   
 
 
 
End With   
   
 
   
 
   
 
 
 
   
   
 
   
 
 
 
End If   
   
 
   
 
   
 
 
 
   
   
 
   
 
 
 
End If   
   
 
   
 
   
 
 
 
   
   
 
   
 
 
 
If strUserDockStatesFromDB = String.Empty Then   
   
 
   
 
   
 
 
 
   
   
 
   
 
 
 
'reload all the default control   
   
 
   
 
   
 
 
 
   
   
 
CreateDefaultRadDock()  
 
   
 
 
 
End If   
   
 
   
 
   
 
 
 
   
   
 
   
 
 
 
Return strUserDockStatesFromDB   
   
 
   
 
 
 
End Function   
   
 
   
 
   
 
 
 
 
   
   
 
   
 
 
 
Private Sub loadData()   
   
 
   
 
 
 
'load View Category   
   
 
   
 
   
 
 
 
   
   
 
   
 
   
 
 
 
   
   
 
 
 
End Sub   
   
 
   
 
   
 
   
 
   
   
 
   
 
 
 
Private Function CreateRadDockFromState(ByVal state As DockState) As RadDock   
   
 
   
 
 
 
Dim dock As New RadDock()   
   
 
   
 
 
 
dock.DockMode = DockMode.Docked   
   
 
   
 
   
 
 
 
   
   
 
dock.ID =   
 
 
 
String.Format("RadDock{0}", state.UniqueName)   
   
 
dock.ApplyState(state)  
 
dock.EnableAnimation =   
 
 
 
True   
   
 
   
 
   
 
 
 
   
   
 
   
 
 
 
dock.Commands.Add(New DockCloseCommand())   
   
 
dock.Commands.Add(  
 
 
 
New DockExpandCollapseCommand())   
   
 
   
 
 
 
Return dock   
   
 
   
 
 
 
End Function 
 
   
 
   
 
   
 
 
 
 
   
   
 
   
 
 
 
Private Function CreateRadDock(ByVal strTitle As String) As RadDock   
   
 
   
 
 
 
Dim docksCount As Integer = CurrentDockStates.Count   
   
 
   
 
 
 
Dim dock As New RadDock()   
   
 
dock.DockMode = DockMode.Docked  
 
dock.UniqueName = Guid.NewGuid().ToString()  
 
dock.ID =   
 
 
 
String.Format("RadDock{0}", dock.UniqueName)   
   
 
dock.Title = strTitle  
 
   
 
 
 
'dock.EnableAnimation = True   
   
 
   
 
   
 
 
 
   
   
 
dock.Text =   
 
 
 
String.Format("Added at {0}", DateTime.Now)   
   
 
dock.Width = Unit.Pixel(100)  
 
dock.BorderWidth = Unit.Pixel(2)  
 
dock.BorderColor = Color.LightGray  
 
dock.Commands.Add(  
 
 
 
New DockCloseCommand())   
   
 
dock.Commands.Add(  
 
 
 
New DockExpandCollapseCommand())   
   
 
   
 
 
 
dock.CommandsAutoPostBack = True   
   
 
   
 
   
 
 
 
   
   
 
   
 
 
 
Return dock   
   
 
   
 
 
 
End Function   
   
 
   
 
   
 
 
 
   
   
 
   
 
 
 
'when user first time load Dock layout, it will load all the control to three radzone   
   
 
   
 
   
 
 
 
   
   
 
   
 
 
 
Private Sub CreateDefaultRadDock()  
 
   
 
   
 
 
 
 
Dim index As Integer   
   
 
   
 
   
 
 
 
   
   
 
   
 
 
 
Dim DockList As New ArrayList()   
   
 
   
 
 
 
Dim intCount As Integer = 0   
   
 
   
 
 
 
Dim intReminder As Integer   
   
 
   
 
   
 
 
 
   
   
 
   
 
 
 
Dim dock As RadDock   
   
 
   
 
 
 
If Not Me.chkDockList.Items Is Nothing Then   
   
 
   
 
   
 
 
 
   
   
 
intCount =   
 
 
 
Me.chkDockList.Items.Count   
   
 
   
 
 
 
End If   
   
 
   
 
   
 
   
 
 
 
   
   
 
   
 
 
 
For index = 0 To intCount - 1   
   
 
dock = CreateRadDock(chkDockList.Items(index).Text)  
 
intReminder = index   
 
 
 
Mod 3   
   
 
   
 
 
 
Select Case intReminder   
   
 
   
 
 
 
Case 0   
   
 
RadDockZone1.Controls.Add(dock)  
 
   
 
 
 
Case 1   
   
 
RadDockZone2.Controls.Add(dock)  
 
   
 
 
 
Case 2   
   
 
RadDockZone3.Controls.Add(dock)  
 
   
 
 
 
End Select   
   
 
   
 
   
 
 
 
   
   
 
   
 
 
 
Me.chkDockList.Items(index).Selected = True   
   
 
   
 
   
 
 
 
   
   
 
   
 
 
 
'We want to save the dock state every time a dock is moved.   
   
 
   
 
   
 
 
 
   
   
 
CreateSaveStateTrigger(dock)  
 
   
 
 
 
'Load the selected widget   
   
 
   
 
   
 
 
 
   
   
 
dock.Tag = chkDockList.Items(index).Value  
 
LoadWidget(dock)  
 
   
 
 
 
Next index   
   
 
   
 
 
 
End Sub 
 
 
   
   
 
Private 
 
   
 
Sub CreateSaveStateTrigger(ByVal dock As RadDock)   
   
 
   
 
 
 
'Ensure that the RadDock control will initiate postback   
   
 
   
 
   
 
 
 
   
   
 
   
 
 
 
' when its position changes on the client or any of the commands is clicked.   
   
 
   
 
   
 
 
 
   
   
 
   
 
 
 
'Using the trigger we will "ajaxify" that postback.   
   
 
   
 
   
 
 
 
   
   
 
dock.AutoPostBack =   
 
 
 
True   
   
 
   
 
   
 
 
 
   
   
 
dock.CommandsAutoPostBack =   
 
 
 
True   
   
 
   
 
   
 
 
 
   
   
 
   
 
 
 
Dim saveStateTrigger As New AsyncPostBackTrigger()   
   
 
saveStateTrigger.ControlID = dock.ID  
 
saveStateTrigger.EventName =   
 
 
 
"DockPositionChanged"   
   
 
   
 
   
 
 
 
   
   
 
UpdatePanel1.Triggers.Add(saveStateTrigger)  
 
saveStateTrigger =   
 
 
 
New AsyncPostBackTrigger()   
   
 
saveStateTrigger.ControlID = dock.ID  
 
saveStateTrigger.EventName =   
 
 
 
"Command"   
   
 
   
 
   
 
 
 
   
   
 
UpdatePanel1.Triggers.Add(saveStateTrigger)  
 
   
 
 
 
End Sub   
   
 
   
 
   
 
 
 
   
   
 
   
 
   
 
 
 
Private Sub LoadWidget(ByVal dock As RadDock)   
   
 
   
 
 
 
If String.IsNullOrEmpty(dock.Tag) Then   
   
 
   
 
   
 
 
 
   
   
 
   
 
 
 
Return   
   
 
   
 
   
 
 
 
   
   
 
   
 
 
 
End If   
   
 
   
 
   
 
 
 
   
   
 
   
 
 
 
Dim widget As Control = LoadControl(dock.Tag)   
   
 
dock.ContentContainer.Controls.Add(widget)  
 
   
 
 
 
End Sub   
   
 
 
 
 
 
 
   
 
Protected Sub RadDockLayout1_LoadDockLayout(ByVal sender As Object, ByVal e As DockLayoutEventArgs) Handles RadDockLayout1.LoadDockLayout   
   
 
   
 
 
 
Try   
   
 
 
 
   
 
Dim serializedList As String   
   
 
 
 
   
 
If Not ViewState("UserDockStatesFromDB") Is Nothing Then   
   
 
 
 
serializedList = ViewState(  
 
"UserDockStatesFromDB")   
   
 
   
 
 
 
End If   
   
 
 
 
   
 
If serializedList <> Nothing Then   
   
 
 
 
   
 
Dim states As String() = serializedList.Split("|"c)   
   
 
   
 
 
 
Dim i As Integer = 0   
   
 
   
 
 
 
While i < states.Length   
   
 
   
 
 
 
Dim state As DockState = DockState.Deserialize(states(i))   
   
 
e.Positions(state.UniqueName) = state.DockZoneID  
 
e.Indices(state.UniqueName) = state.Index  
 
   
 
 
 
System.Math.Max(System.Threading.Interlocked.Increment(i), i - 1)   
   
 
   
 
 
 
End While   
   
 
 
 
   
 
End If   
   
 
 
 
   
 
Catch ex As Exception   
   
 
   
 
 
 
End Try   
   
 
 
 
   
 
End Sub 
 
 
 
   
 
 
 
   
 
Protected Sub RadDockLayout1_SaveDockLayout(ByVal sender As Object, ByVal e As DockLayoutEventArgs) Handles RadDockLayout1.SaveDockLayout   
   
 
   
 
 
 
Dim stateList As List(Of DockState) = RadDockLayout1.GetRegisteredDocksState()   
   
 
   
 
 
 
Dim serializedList As New StringBuilder()   
   
 
   
 
 
 
Dim i As Integer = 0   
   
 
   
 
 
 
While i < stateList.Count   
   
 
serializedList.Append(stateList(i).ToString())  
 
serializedList.Append(  
 
 
 
"|")   
   
 
System.Math.Max(System.Threading.Interlocked.Increment(i), i - 1)  
 
   
 
 
 
End While   
   
 
 
 
   
 
Dim dockState As String = serializedList.ToString()   
   
 
   
 
 
 
If dockState.Trim() <> String.Empty Then   
   
 
 
 
ViewState(  
 
"UserDockStatesFromDB") = dockState   
   
 
   
 
 
 
End If   
   
 
 
 
   
 
End Sub   
   
 
   
 
 
 
   
 
'+---------------------------------------------------------------------------------------------   
   
 
 
 
   
 
'| Method : ButtonSave_Click   
   
 
 
 
   
 
'| Purpose : save all the state when user click Save button   
   
 
 
 
   
 
'| Returns : Boolean   
   
 
 
 
   
 
'+---------------------------------------------------------------------------------------------   
   
 
 
 
   
 
Protected Sub ButtonSave_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnSave.Click   
   
 
   
 
 
 
Dim dockState As String   
   
 
 
 
   
 
If Not ViewState("UserDockStatesFromDB") Is Nothing Then   
   
 
 
 
dockState = ViewState(  
 
"UserDockStatesFromDB")   
   
 
   
 
 
 
End If 
 
If GetControlData(dockState) Then   
   
 
 
 
SaveUserDockState(FormData)  
 
   
 
End If   
   
 
 
 
   
 
End Sub   
   
 
 
 
 
 
 

Pero
Telerik team
 answered on 24 Feb 2010
1 answer
106 views
Hello,

         I am using Rad Scheduler to display meeting details.
         Now, I enter the meeting details by selecting the date from RadDatePickter & Time from Time Picker.
           also, i enter the title for the meeting in Text Box.

         Now the issue is that, if for e.g. i select DATE : 02/19/2010 & TIME : 12:00 AM,
             the the value entered in the database will be 2010-02-19 00:00:00.000
                                                                   [ I am using SQL SERVER 2005 Database with this field as Date Time]
          Now when i bind the Scheduler with all the records from the database,
               the records which are having TIME : 12:00 AM are not bound to Scheduler.

           And one more thing, If i change the Scheduler View to MONTH, then all the records are bound.
           so, it does not work with Day & Week View as they both have TIME specification.

         Please reply me as soon as possible, as i am having too much issues regarding this,


Thanks,
Kunal Patel
      
        



           
     

Peter
Telerik team
 answered on 24 Feb 2010
5 answers
112 views
Hi,

I'm trying to set the pager radcombobox in my grid to populate itself with values from my web.config file.  This is working, except that the following is happening: when I change my number of items to show on one page from 10 to 2 (for testing; I only have 7 items in the grid) two items show up, but when I try to navigate through the grid, it resets itself to 10 and I get an empty grid, (i.e., if I click the next button it thinks it's on page 2 but it also thinks that there's only one page there, so it shows nothing).  When I click back to page 1, it shows all my records.  Here's the code:

ASPX:
    <telerik:RadGrid ID="rgUsers" runat="server" 
        OnNeedDataSource="rgUsers_NeedDataSource" OnItemCreated="rgAdminUsers_ItemCreated">  
        <MasterTableView DataKeyNames="UserName">  
            <Columns> 
                <telerik:GridCheckBoxColumn DataField="IsOnline" DataType="System.Boolean" 
                    HeaderText="Is Online?" UniqueName="IsOnline" > 
                </telerik:GridCheckBoxColumn> 
                <telerik:GridBoundColumn DataField="UserName" HeaderText="UserName" UniqueName="UserName">  
                </telerik:GridBoundColumn> 
                <telerik:GridBoundColumn DataField="LastLoginDate" HeaderText="Last Logged In" UniqueName="column">  
                </telerik:GridBoundColumn> 
                <telerik:GridTemplateColumn HeaderText="Is Approved?" UniqueName="IsApproved" SortExpression="IsApproved" DataField="IsApproved">  
                    <ItemTemplate> 
                        <asp:CheckBox ID="cbIsApproved" runat="server" AutoPostBack="true" Checked='<%# Bind("IsApproved") %>'   
                            OnCheckedChanged="gvUsers_UpdateIsApproved"  /> 
                    </ItemTemplate> 
                </telerik:GridTemplateColumn> 
                <telerik:GridTemplateColumn HeaderText="Is Locked Out?" UniqueName="IsLockedOut" SortExpression="IsLockedOut" DataField="IsLockedOut">  
                    <ItemTemplate> 
                        <asp:CheckBox ID="cbIsLockedOut" runat="server" AutoPostBack="true" Checked='<%# Bind("IsLockedOut") %>'   
                            OnCheckedChanged="gvUsers_UpdateLockedOut" Enabled='<%# Bind("IsLockedOut") %>' /> 
                    </ItemTemplate> 
                </telerik:GridTemplateColumn> 
                <telerik:GridTemplateColumn HeaderText="Role(s)" UniqueName="Roles" DataField="Roles" AllowFiltering="False">  
                    <ItemTemplate> 
                        <%# String.Join(", ",Roles.GetRolesForUser(DataBinder.Eval(Container.DataItem, "UserName").ToString())) %> 
                    </ItemTemplate> 
                </telerik:GridTemplateColumn> 
                <telerik:GridTemplateColumn HeaderText="Petition(s)" UniqueName="Petitions" DataField="Petitions" AllowFiltering="False">  
                    <ItemTemplate> 
                        <%# new ProfileCommon().GetProfile(DataBinder.Eval(Container.DataItem, "UserName").ToString()).Petitions.Replace(", ","<br />") %> 
                    </ItemTemplate> 
                </telerik:GridTemplateColumn> 
                <telerik:GridTemplateColumn UniqueName="TemplateColumn" AllowFiltering="False">  
                    <ItemTemplate> 
                        <asp:Button ID="btnEditRoles" runat="server" CausesValidation="false" CommandArgument='<%# DataBinder.Eval(Container.DataItem, "UserName").ToString() %>' 
                            CommandName="EditRoles" Text="Edit Roles" OnClick="EditRoles" /> 
                        <asp:Button ID="btnEditPetitions" runat="server" CausesValidation="false" CommandArgument='<%# DataBinder.Eval(Container.DataItem, "UserName").ToString() %>' 
                            CommandName="EditRoles" Text="Edit Petitions" OnClick="EditPetitions" /> 
                        <asp:Button ID="btnChangePassword" runat="server" CausesValidation="false" CommandArgument='<%# DataBinder.Eval(Container.DataItem, "UserName").ToString() %>' 
                            CommandName="ChangePassword" Text="Change Password" OnClick="ChangePassword" /> 
                        <asp:Button ID="btnUserInfo" runat="server" CausesValidation="false" CommandArgument='<%# DataBinder.Eval(Container.DataItem, "UserName").ToString() %>' 
                            CommandName="ViewUserInfo" Text="View User Info" OnClick="ViewUserInfo" /> 
                    </ItemTemplate> 
                </telerik:GridTemplateColumn> 
            </Columns> 
        </MasterTableView> 
    </telerik:RadGrid> 
 

CS:
    protected void rgAdminUsers_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e)  
    {  
        // Pull Number of Entries per page in page from web.config appsettings.  
        if (e.Item is GridPagerItem)  
        {  
            RadComboBox myPageSizeCombo = (RadComboBox)e.Item.FindControl("PageSizeComboBox");  
            myPageSizeCombo.Items.Clear();  
            string strPageSizes = ConfigurationManager.AppSettings["PageSizes"];  
            string[] arrPageSizes = strPageSizes.Split(',');  
            for (int x = 0; x < arrPageSizes.Length; x++)  
            {  
                RadComboBoxItem myRadComboBoxItem = new RadComboBoxItem(arrPageSizes[x]);  
                myPageSizeCombo.Items.Add(myRadComboBoxItem);  
                myPageSizeCombo.FindItemByText(arrPageSizes[x]).Attributes.Add("ownerTableViewId", rgUsers.MasterTableView.ClientID);   
            }  
            myPageSizeCombo.FindItemByText(e.Item.OwnerTableView.PageSize.ToString()).Selected = true;  
        }  
    }  
 
Laurie
Top achievements
Rank 2
 answered on 24 Feb 2010
3 answers
123 views
I have a form with three grids each has a edititemtemplate with several fields and an update/insert button and a cancel button.

I need to access the content of each field prior to update/insert to make sure the content is valid.

One of the grids is named FULEGRID.  On the click event for the update/insert needs to access the tbx fields inthe template but I can't seem construct the statement needed to 'view' their content.  Give the following code can someone help out?

Cliff

Here is the source for this grid

 

<telerik:RadGrid ID="fuelgrid" runat="server" DataSourceID="SqlDataSource1"  GridLines="None"     AllowAutomaticInserts="True"     AllowAutomaticUpdates="True" AutoGenerateEditColumn="True" Skin="Hay">

 

 

<MasterTableView AutoGenerateColumns="False" CommandItemDisplay="Top" DataKeyNames="Id"

 

 

DataSourceID="SqlDataSource1">

 

 

<RowIndicatorColumn>

 

 

<HeaderStyle Width="20px" />

 

 

</RowIndicatorColumn>

 

 

<ExpandCollapseColumn>

 

 

<HeaderStyle Width="20px" />

 

 

</ExpandCollapseColumn>

 

 

<Columns>

 

 

<telerik:GridEditCommandColumn>

 

 

</telerik:GridEditCommandColumn>

 

 

<telerik:GridBoundColumn DataField="Id" DataType="System.Int64" HeaderText="Id" ReadOnly="True"

 

 

SortExpression="Id" UniqueName="Id" Visible="False">

 

 

</telerik:GridBoundColumn>

 

 

<telerik:GridBoundColumn DataField="fleet_id" DataType="System.Int64" HeaderText="fleet_id" SortExpression="fleet_id" UniqueName="fleet_id" Visible="False">

 

 

</telerik:GridBoundColumn>

 

 

<telerik:GridBoundColumn DataField="beginning_miles" DataType="System.Double" HeaderText="Starting Miles"

 

 

SortExpression="beginning_miles" UniqueName="beginning_miles">

 

 

<HeaderStyle HorizontalAlign="Center" Width="80px" />

 

 

</telerik:GridBoundColumn>

 

 

<telerik:GridBoundColumn DataField="ending_miles" DataType="System.Double" HeaderText="Ending Miles"

 

 

SortExpression="ending_miles" UniqueName="ending_miles">

 

 

<HeaderStyle HorizontalAlign="Center" Width="80px" />

 

 

</telerik:GridBoundColumn>

 

 

<telerik:GridBoundColumn DataField="gas_date" DataFormatString="{0:MM/dd/yyyy}" DataType="System.DateTime"

 

 

HeaderText="Fill-up Date" SortExpression="gas_date" UniqueName="gas_date">

 

 

<HeaderStyle HorizontalAlign="Center" Width="80px" />

 

 

</telerik:GridBoundColumn>

 

 

<telerik:GridBoundColumn DataField="gas_gallons" DataType="System.Double" HeaderText="Gallons"

 

 

SortExpression="gas_gallons" UniqueName="gas_gallons">

 

 

<HeaderStyle HorizontalAlign="Center" Width="80px" />

 

 

</telerik:GridBoundColumn>

 

 

<telerik:GridBoundColumn DataField="gas_amt" DataType="System.Decimal" HeaderText="Price"

 

 

SortExpression="gas_amt" UniqueName="gas_amt" DataFormatString="{0:C}">

 

 

<HeaderStyle HorizontalAlign="Center" Width="80px" />

 

 

</telerik:GridBoundColumn>

 

 

<telerik:GridBoundColumn DataField="create_date" DataType="System.DateTime" HeaderText="create_date"

 

 

SortExpression="create_date" UniqueName="create_date" Visible="False">

 

 

</telerik:GridBoundColumn>

 

 

<telerik:GridBoundColumn DataField="create_id" HeaderText="create_id" SortExpression="create_id"

 

 

UniqueName="create_id" Visible="False">

 

 

</telerik:GridBoundColumn>

 

 

</Columns>

 

 

<EditFormSettings EditFormType="Template">

 

 

<EditColumn UniqueName="EditCommandColumn1">

 

 

</EditColumn>

 

 

<FormTemplate>

 

 

<table style="width: 245px; height: 117px">

 

 

<tr>

 

 

<td>

 

 

<asp:Label ID="lblstart" runat="server" Text="Starting Miles"></asp:Label></td>

 

 

<td style="width: 8px">

 

 

<asp:TextBox ID="tbxstartingmiles" runat="server" Text='<%# Bind("beginning_miles") %>'></asp:TextBox></td>

 

 

<td style="width: 3px">

 

 

<asp:Label ID="Label1" runat="server" Text="######"></asp:Label></td>

 

 

</tr>

 

 

<tr>

 

 

<td>

 

 

<asp:Label ID="lblend" runat="server" Text="Ending Miles"></asp:Label></td>

 

 

<td style="width: 8px">

 

 

<asp:TextBox ID="tbxendingmiles" runat="server" Text='<%# Bind("ending_miles") %>'></asp:TextBox></td>

 

 

<td style="width: 3px">

 

 

<asp:Label ID="Label2" runat="server" Text="######"></asp:Label></td>

 

 

</tr>

 

 

<tr>

 

 

<td>

 

 

<asp:Label ID="lblgallons" runat="server" Text="Gallons"></asp:Label></td>

 

 

<td style="width: 8px">

 

 

<asp:TextBox ID="tbxgallons" runat="server" Text='<%# Bind("gas_gallons") %>'></asp:TextBox></td>

 

 

<td style="width: 3px">

 

 

<asp:Label ID="Label3" runat="server" Text="###.#"></asp:Label></td>

 

 

</tr>

 

 

<tr>

 

 

<td>

 

 

<asp:Label ID="lblgamt" runat="server" Text="Price"></asp:Label></td>

 

 

<td style="width: 8px">

 

 

<asp:TextBox ID="tbxgamt" runat="server" Text='<%# Bind("gas_amt") %>'></asp:TextBox></td>

 

 

<td style="width: 3px">

 

 

<asp:Label ID="Label4" runat="server" Text="$$$$.$$"></asp:Label></td>

 

 

</tr>

 

 

<tr>

 

 

<td>

 

 

<asp:Label ID="lblgdate" runat="server" Text="Fill-up Date"></asp:Label>

 

 

</td>

 

 

<td style="width: 8px">

 

 

<asp:TextBox ID="tbxgdate" runat="server" Text='<%# Bind("gas_date") %>'></asp:TextBox></td>

 

 

<td style="width: 3px">

 

 

<asp:Label ID="Label5" runat="server" Text="mm/dd/yyyy"></asp:Label></td>

 

 

</tr>

 

 

<tr>

 

 

<td colspan="3">

 

 

<asp:Button ID="btnupdate" runat="server"

 

 

Text='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Update" %>'

 

 

CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>' OnClick="btnupdate_Click"/>

 

 

</td>

 

 

</tr>

 

 

<tr>

 

 

<td colspan="3">

 

 

<asp:Button ID="btncancel" runat="server" Text="Cancel" CausesValidation="false"

 

 

CommandName="Cancel" />

 

 

</td>

 

 

</tr>

 

 

<tr>

 

 

<td colspan="3">

 

 

<asp:TextBox ID="tbxfleetid" runat="server"

 

 

Text='<%# Bind("fleet_id") %>'

 

 

Visible="False"></asp:TextBox>

 

 

<asp:TextBox ID="tbxcreaterid" runat="server"

 

 

Text='<%# Bind("create_id") %>'

 

 

Visible="False">

 

 

</asp:TextBox>

 

 

</td>

 

 

</tr>

 

 

<tr>

 

 

<td colspan="3">

 

 

<asp:Label ID="lblerror" runat="server" Text="Label"></asp:Label></td>

 

 

</tr>

 

 

</table>

 

 

</FormTemplate>

 

 

</EditFormSettings>

 

 

</MasterTableView>

 

 

<FilterMenu EnableTheming="True" Skin="Hay">

 

 

 

 

 

<CollapseAnimation Duration="200" Type="OutQuint" />

 

 

 

 

 

</FilterMenu>

 

 

 

 

 

</telerik:RadGrid>

 

Pavlina
Telerik team
 answered on 24 Feb 2010
1 answer
99 views
hello!! ^^

help me please....!!

picture.... see~


i need Grid last column is full size view ~ 

why Grid Last Column The Cutted?   why?? why??

help me please!!!  
Martin
Telerik team
 answered on 24 Feb 2010
2 answers
157 views
Hi all.
I have a column where I have only three possible values. I want to create a filter column with checkboxes, when I can choose one (or more) of them. I have a radgrid populated using webservice+js, so I want to do it in pure js. For filtering other columns I using a dynamic linq. How can I do that?
Tsvetoslav
Telerik team
 answered on 24 Feb 2010
1 answer
91 views
Unable to delete file "C:\Users\jpwaldin\Documents\Visual Studio 2010\Projects\RadControlsWebApplication1\RadControlsWebApplication1\bin\Telerik.Web.UI.xml". Access to the path 'C:\Users\jpwaldin\Documents\Visual Studio 2010\Projects\RadControlsWebApplication1\RadControlsWebApplication1\bin\Telerik.Web.UI.xml' is denied. RadControlsWebApplication1

When running my app in debug I get the above error/warning.  I am not doing anything with the xml file.  Why is this happening and how do I correct it from happening again?

I am using Windows 7 with VS2010 RC

Thanks, Joe
Pavel
Telerik team
 answered on 24 Feb 2010
1 answer
115 views
I've been trying to clean up some pages i've put together using the RadGrid. I've been using the API reference to look up the default values of fields, and it seems random if a reference page lists the properties default value or not. It would definitely help me out if the default values of all properties were listed.

Thanks
Sebastian
Telerik team
 answered on 24 Feb 2010
5 answers
574 views
Hi,

I try to bind master detail on client side. It binds master table but not its associate detail table. Can you help me in this regard that where I get wrong?

Thanks
My Code:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default4.aspx.cs" Inherits="TestGrid._Default4" %> 
 
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik"  %> 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
 
<html xmlns="http://www.w3.org/1999/xhtml" > 
<head runat="server"> 
    <title>Untitled Page</title> 
     
    <script type="text/javascript" src="script/jquery/1.3.2/jquery.js"></script> 
    <script type="text/javascript" src="json.js"></script> 
    <telerik:RadScriptBlock ID="SB" runat="server">  
        
    <script type="text/javascript"> 
        
    var companies = null; 
    var empId = -1000; 
    var curDataItem = null; 
    var companyId = -100; 
     
    $(document).ready(pageLoad); 
     
    function pageLoad() 
    { 
        companies = [{"CompanyID":1,"CompanyName":"Moftak","Employees":[{"CompanyId":1,"FirstName":"Naeem","EmployeeID":1,"LastName":"Dad","Title":"","TitleId":0,"BirthDate":"","ShiftStart":"","JoinDate":""},{"CompanyId":1,"FirstName":"Nabil","EmployeeID":2,"LastName":"Manzoor","Title":"","TitleId":0,"BirthDate":"","ShiftStart":"","JoinDate":""}]}];         
         
        var grd = $find("<%= RadGrid1.ClientID %>");       
        if(grd != null)        
        {               
            grd.get_masterTableView().rebind(); 
            grd.get_detailTables()[0].rebind(); 
        }        
    }        
        
    function OnCommand(sender,args) 
    { 
       args.set_cancel(true); 
        
       if(args.get_commandName() == "RebindGrid") 
       {    
          resetContainers(); 
                                        
          if(args.get_tableView().get_name() == "Company") 
          {             
            sender.get_masterTableView().set_dataSource(companies); 
            sender.get_masterTableView().dataBind();                     
          } 
           
          if(args.get_tableView().get_name() == "Employee") 
          {             
            args.get_tableView().set_dataSource(companies[0].Employees); 
            args.get_tableView().dataBind();                     
          } 
       }                     
    } 
    function popupAddEmployee() 
    { 
        var oWnd = window.radopen("add-employee.aspx" , "radWindow1"); 
        oWnd.SetSize(500,400); 
        oWnd.Center(); 
        return false; 
    } 
    function addEmployee(employee) 
    {        
        employee.CompanyID = 1;                  
        employee.EmployeeID = empId--; 
        var grd = $find("<%= RadGrid1.ClientID %>"); 
                 
        for(var i=0;i<companies.length;i++) 
        { 
            if(companies[i].CompanyID == employee.CompanyID) 
            { 
                var company = companies[i]; 
                if(company != null) 
                { 
                    company.Employees[company.Employees.length] = employee;            
                    
                    document.getElementById("hdCompanies").value = $.toJSON(companies);   
                 
                    //grd.get_masterTableView().rebind(); 
                     
                    grd.get_detailTables()[0].rebind(); 
                } 
                break; 
            } 
        }                 
    }       
    </script> 
    </telerik:RadScriptBlock> 
</head> 
<body > 
     
    <telerik:RadWindowManager ID="eiditCustomFields" runat="server" DestroyOnClose="true" ShowContentDuringLoad="false" Skin="Office2007"> 
    <Windows> 
        <telerik:RadWindow ID="radWindow1" runat="server" style="display:none" Behavior="default"></telerik:RadWindow> 
    </Windows> 
</telerik:RadWindowManager> 
     
    <form id="form1" runat="server"> 
    <div> 
        <asp:ScriptManager ID="ScriptManager1" runat="server" ></asp:ScriptManager> 
        <telerik:RadGrid ID="RadGrid1" runat="server" OnNeedDataSource="RadGrid1NeedDataSource" OnDetailTableDataBind = "DetailTableDataBind"  > 
        <MasterTableView AutoGenerateColumns="false"  AllowAutomaticInserts="true" DataKeyNames="CompanyID" Name="Company" 
         CommandItemDisplay="Top" HierarchyLoadMode="Client">                  
         
        <Columns> 
        <telerik:GridBoundColumn DataField="CompanyID" UniqueName="CompanyID"  Display="false" DataType="System.Int32" >    
         
        </telerik:GridBoundColumn>               
         
        <telerik:GridBoundColumn DataField="CompanyName" UniqueName="CompanyName" HeaderText="Company Name">               
        <ItemStyle Width="100px" /> 
        </telerik:GridBoundColumn>                           
                                                                                                 
        </Columns> 
         
        <DetailTables> 
            <telerik:GridTableView runat="server" DataKeyNames="EmployeeID" AutoGenerateColumns="false" Name="Employee"  > 
             
             <ParentTableRelation> 
                 <telerik:GridRelationFields DetailKeyField="CompanyID" MasterKeyField="CompanyID" /> 
             </ParentTableRelation> 
              
            <ExpandCollapseColumn Visible="False"> 
                <HeaderStyle Width="19px" /> 
            </ExpandCollapseColumn> 
             
            <RowIndicatorColumn Visible="False"> 
               <HeaderStyle Width="20px" /> 
            </RowIndicatorColumn> 
             
            <Columns> 
                <telerik:GridBoundColumn DataField="CompanyID" Display="false" DataType="System.Int32" >    
                 
                </telerik:GridBoundColumn>  
                <telerik:GridBoundColumn DataField="EmployeeID" Display="false" DataType="System.Int32" >    
                 
                </telerik:GridBoundColumn>               
                 
                <telerik:GridBoundColumn DataField="FirstName" HeaderText="First Name">               
                <ItemStyle Width="100px" /> 
                </telerik:GridBoundColumn> 
                
                <telerik:GridBoundColumn DataField="LastName" HeaderText="Last Name">               
                <ItemStyle Width="100px" /> 
                </telerik:GridBoundColumn> 
                 
                <telerik:GridBoundColumn DataField="TitleId" Display="false" DataType="System.Int32">                     
                </telerik:GridBoundColumn> 
                 
                <telerik:GridBoundColumn DataField="Title" HeaderText="Title" UniqueName="Title" >             
                <ItemStyle Width="100px" /> 
                </telerik:GridBoundColumn>         
                 
                <telerik:GridBoundColumn DataField="BirthDate"  HeaderText="BirthDate" >             
                <ItemStyle Width="100px" /> 
                </telerik:GridBoundColumn> 
                    
                <telerik:GridBoundColumn DataField="ShiftStart" UniqueName="ShiftStart" HeaderText="Shift Start" >             
                <ItemStyle Width="150px" /> 
                </telerik:GridBoundColumn>      
                 
                <telerik:GridBoundColumn DataField="JoinDate" UniqueName="JoinDate" HeaderText="JoinDate" >             
                <ItemStyle Width="150px" /> 
                </telerik:GridBoundColumn>    
                                                                                                 
            </Columns> 
            
             
            </telerik:GridTableView> 
        </DetailTables> 
                 
        <CommandItemTemplate> 
        <input type="button" value="Add Employee" id="add" onclick="popupAddEmployee();" /> 
        </CommandItemTemplate> 
                 
        </MasterTableView> 
        <ClientSettings> 
        <ClientEvents OnCommand="OnCommand"  /> 
        </ClientSettings> 
        </telerik:RadGrid>      
         
    </div> 
             
    </form> 
</body> 
</html> 
 
Sebastian
Telerik team
 answered on 24 Feb 2010
Narrow your results
Selected tags
Tags
+? more
Top users last month
Jake
Top achievements
Rank 1
RBarnes
Top achievements
Rank 1
Iron
Iron
Rami
Top achievements
Rank 1
Iron
Veteran
Nathan
Top achievements
Rank 1
Kumeri
Top achievements
Rank 1
Iron
Veteran
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jake
Top achievements
Rank 1
RBarnes
Top achievements
Rank 1
Iron
Iron
Rami
Top achievements
Rank 1
Iron
Veteran
Nathan
Top achievements
Rank 1
Kumeri
Top achievements
Rank 1
Iron
Veteran
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?