or
<
a
href
=
"#"
onclick
=
"getAddWindow(<%# eval("
p_id") %>)" class="CheckUsername" title='<%# eval("p_title") %>'>
<%#IIf(Not IsDBNull(Eval("p_video")) And Not Eval("p_video") Is Nothing, "<
img
src
=
'http://img.youtube.com/vi/" & Eval("p_video") & "/0.jpg'
width
=
'150'
border
=
'0'
/>", "")%>
<
asp:Panel
ID
=
"Panel1"
runat
=
"server"
Visible='<%# showvisible(eval("p_image")) %>'>
<
telerik:RadBinaryImage
runat
=
"server"
ID
=
"RadBinaryImage1"
DataValue='<%# convertvarbinary(eval("p_image")) %>'
AutoAdjustImageControlSize="false" Height='150px' Width="150px" BorderWidth="0"
BorderStyle="none" />
</
asp:Panel
>
</
a
>
<
telerik:RadScheduler
ID
=
"RadSchedulerCalendarEvents"
runat
=
"server"
Width
=
"100%"
Height
=
"500"
BorderStyle
=
"None"
BorderWidth
=
"0"
HoursPanelTimeFormat
=
"h:mm tt"
ShowFullTime
=
"true"
TimeSlotContextMenuSettings-EnableDefault
=
"true"
StartInsertingInAdvancedForm
=
"true"
DisplayRecurrenceActionDialogOnMove
=
"true"
EnableDatePicker
=
"False"
EnableDescriptionField
=
"True"
DataSourceID
=
"SqlDataSourceEvents"
DataKeyField
=
"evtID"
DataStartField
=
"evtStartTime"
DataEndField
=
"evtEndTime"
DataSubjectField
=
"evtName"
DataDescriptionField
=
"evtDescription"
DataReminderField
=
"evtReminder"
DataRecurrenceField
=
"evtRecurrenceRule"
DataRecurrenceParentKeyField
=
"evtRecurrenceParentID"
OnClientAppointmentInserting
=
"RadSchedulerCalendarEvents_OnClientAppointmentInserting"
OnClientAppointmentEditing
=
"RadSchedulerCalendarEvents_OnClientAppointmentEditing"
OnClientAppointmentMoveEnd
=
"RadSchedulerCalendarEvents_OnClientAppointmentMoveEnd"
OnClientAppointmentResizeEnd
=
"RadSchedulerCalendarEvents_OnClientAppointmentResizeEnd"
>
<
AdvancedForm
Modal
=
"true"
/>
<
TimeSlotContextMenus
>
<
telerik:RadSchedulerContextMenu
runat
=
"server"
ID
=
"SchedulerTimeSlotContextMenu"
>
<
Items
>
<
telerik:RadMenuItem
Text
=
"New Event"
ImageUrl
=
"/Images/Icons16x16/calendar.png"
Postback
=
"false"
NavigateUrl
=
"javascript: parent.newEvent('Calendar Event');"
/>
<
telerik:RadMenuItem
IsSeparator
=
"true"
/>
<
telerik:RadMenuItem
Text
=
"Go to today"
Value
=
"CommandGoToToday"
/>
</
Items
>
</
telerik:RadSchedulerContextMenu
>
</
TimeSlotContextMenus
>
<
AppointmentContextMenuSettings
EnableDefault
=
"true"
/>
<
Localization
ContextMenuAddAppointment
=
"New Event"
ContextMenuAddRecurringAppointment
=
"New Recurring Event"
ContextMenuEdit
=
"Edit Event"
/>
</
telerik:RadScheduler
>
int
result = cmd.ExecuteNonQuery();
if
(result < 1)
{
String strFail =
"<script type=text/javascript> var oWnd = radopen(null, 'fail');</script>"
;
ClientScriptManager sm = Page.ClientScript;
sm.RegisterStartupScript(
this
.GetType(),
"upFail"
, strFail);
}
else
{
String strSuccess =
"<script type=text/javascript> var oWnd = radopen(null, 'success');</script>"
;
ClientScriptManager sm = Page.ClientScript;
sm.RegisterStartupScript(
this
.GetType(),
"upSuccess"
, strSuccess);
ctl00$ctl00$MasterMainContent$MainContent$ucSetupPosition$RadGrid1$ctl00$ctl02$ctl03$RadComboBoxPositionCategory
ctl00$ctl00$MasterMainContent$MainContent$ucSetupPosition$RadGrid1$ctl00$ctl11$RadComboBoxPositionCategory
<
script
type
=
"text/javascript"
>
// Must hard code IDs due to Telerik quirkiness
var radComboPosCatID = 'RadComboBoxPositionCategory';
function RadComboBoxSport_SelectedIndexChanged(sender, eventArgs) {
var comboSport = eventArgs.get_item();
var comboPosCat = GetRadComboBoxFromPage(radComboPosCatID);
if (comboPosCat != null && comboSport.get_value() > 0) {
comboPosCat.clearSelection();
// Fire off call to refresh Position Category dropdown
comboPosCat.requestItems(comboSport.get_value(), false); // false=clear items
}
}
function RadComboBoxPositionCategory_ItemsRequested(sender, eventArgs) {
//TODO: Resolve issue where, if Grid is in Edit mode (vs. insert mode), this method will not fire
// and dropdown will not update!
var comboPosCat = sender;
comboPosCat.set_text(sender.get_items().getItem(0).get_text());
if (sender.get_items().get_count() > 0) {
comboPosCat.showDropDown();
}
}
</
script
>
<
telerik:RadAjaxLoadingPanel
ID
=
"RadAjaxLoadingPanel1"
runat
=
"server"
Skin
=
"WebBlue"
/>
<
telerik:RadAjaxPanel
ID
=
"RadAjaxPanel1"
runat
=
"server"
LoadingPanelID
=
"RadAjaxLoadingPanel1"
>
<
asp:Label
id
=
"StatusMessage"
runat
=
"server"
CssClass
=
"errorText"
/>
<
telerik:RadGrid
ID
=
"RadGrid1"
runat
=
"server"
AllowPaging
=
"True"
AllowSorting
=
"True"
AutoGenerateColumns
=
"false"
Skin
=
"WebBlue"
OnNeedDataSource
=
"RadGrid1_NeedDataSource"
OnUpdateCommand
=
"RadGrid1_UpdateCommand"
OnInsertCommand
=
"RadGrid1_InsertCommand"
OnDeleteCommand
=
"RadGrid1_DeleteCommand"
OnItemDataBound
=
"RadGrid1_ItemDataBound"
>
<
PagerStyle
VerticalAlign
=
"Bottom"
Mode
=
"NextPrev"
/>
<
ClientSettings
Scrolling-AllowScroll
=
"true"
/>
<
MasterTableView
EditMode
=
"PopUp"
DataKeyNames
=
"PositionId,SportId,PositionCategoryId"
CommandItemDisplay
=
"Top"
>
<
EditFormSettings
CaptionFormatString
=
"Edit Position"
InsertCaption
=
"Add Position"
PopUpSettings-Modal
=
"false"
EditColumn-ButtonType
=
"ImageButton"
/>
<
Columns
>
<
telerik:GridEditCommandColumn
ButtonType
=
"ImageButton"
>
<
HeaderStyle
Width
=
"30px"
/>
<
ItemStyle
Width
=
"30px"
HorizontalAlign
=
"Center"
/>
</
telerik:GridEditCommandColumn
>
<
telerik:GridButtonColumn
ButtonType
=
"ImageButton"
CommandName
=
"Delete"
Text
=
"Delete"
UniqueName
=
"DeleteColumn"
ConfirmDialogType
=
"Classic"
ConfirmText
=
"Are you sure you want to delete?"
>
<
HeaderStyle
Width
=
"30px"
/>
<
ItemStyle
Width
=
"30px"
HorizontalAlign
=
"Center"
/>
</
telerik:GridButtonColumn
>
<
telerik:GridTemplateColumn
UniqueName
=
"Sport"
SortExpression
=
"Sport.Name"
HeaderText
=
"Sport"
DataField
=
"Sport.Name"
>
<
ItemTemplate
>
<
asp:Label
ID
=
"lblSport"
runat
=
"server"
Text='<%# Eval("Sport.Name") %>' />
</
ItemTemplate
>
<
EditItemTemplate
>
<
telerik:RadComboBox
runat
=
"server"
ID
=
"RadComboBoxSport"
AutoPostBack
=
"true"
OnClientSelectedIndexChanged
=
"RadComboBoxSport_SelectedIndexChanged"
/>
<
asp:RequiredFieldValidator
runat
=
"server"
ID
=
"rfvSport"
ControlToValidate
=
"RadComboBoxSport"
InitialValue
=
"Select..."
Text
=
"*"
/>
</
EditItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridTemplateColumn
UniqueName
=
"PositionCategory"
SortExpression
=
"PositionCategory.CategoryName"
HeaderText
=
"Position Category"
DataField
=
"PositionCategory.CategoryName"
>
<
ItemTemplate
>
<
asp:Label
ID
=
"lblPositionCategory"
runat
=
"server"
Text='<%# Eval("PositionCategory.CategoryName") %>' />
</
ItemTemplate
>
<
EditItemTemplate
>
<
telerik:RadComboBox
runat
=
"server"
ID
=
"RadComboBoxPositionCategory"
EmptyMessage
=
"Select a sport first..."
OnClientItemsRequested
=
"RadComboBoxPositionCategory_ItemsRequested"
OnItemsRequested
=
"RadComboBoxPositionCategory_ItemsRequested"
/>
<
asp:RequiredFieldValidator
runat
=
"server"
ID
=
"rfvPositionCategory"
ControlToValidate
=
"RadComboBoxPositionCategory"
InitialValue
=
"Select..."
Text
=
"*"
/>
</
EditItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridTemplateColumn
UniqueName
=
"PositionName"
SortExpression
=
"Name"
HeaderText
=
"Position Name"
DataField
=
"Name"
>
<
ItemTemplate
>
<
div
></
div
>
<
asp:Label
ID
=
"lblPositionName"
runat
=
"server"
Text='<%# Eval("Name") %>' />
</
ItemTemplate
>
<
EditItemTemplate
>
<
asp:TextBox
runat
=
"server"
ID
=
"txtPositionName"
Text='<%# Bind("Name") %>' />
<
asp:RequiredFieldValidator
runat
=
"server"
ID
=
"rfvPositionName"
ControlToValidate
=
"txtPositionName"
Text
=
"*"
/>
</
EditItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridBoundColumn
ReadOnly
=
"true"
UniqueName
=
"LastUpdatedDate"
SortExpression
=
"LastUpdatedDate"
HeaderText
=
"Last Updated"
DataField
=
"LastUpdatedDate"
DataFormatString
=
"{0:g}"
AllowSorting
=
"false"
/>
</
Columns
>
</
MasterTableView
>
</
telerik:RadGrid
>
</
telerik:RadAjaxPanel
>
protected
void
Page_Load(
object
sender, EventArgs e)
{
}
#region Grid Events
protected
void
RadGrid1_NeedDataSource(
object
source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
{
PositionCollection positions =
new
PositionCollection();
positions = PositionBuilder.RetrieveList();
RadGrid1.DataSource = positions;
}
protected
void
RadGrid1_ItemDataBound(
object
sender, Telerik.Web.UI.GridItemEventArgs e)
{
try
{
if
(e.Item
is
GridEditableItem && e.Item.IsInEditMode)
{
GridEditableItem item = e.Item
as
GridEditableItem;
#region Sport Dropdown
// Bind values to Sport dropdown list in edit/insert mode
RadComboBox ddlSport = item.FindControl(
"RadComboBoxSport"
)
as
RadComboBox;
SetSportOptions(ddlSport);
// If in "Add" mode, ItemIndex == -1. We only want to load value in edit mode
if
(item.ItemIndex != -1)
{
int
sportId = 0;
Int32.TryParse(item.OwnerTableView.DataKeyValues[item.ItemIndex][
"SportId"
].ToString(),
out
sportId);
ddlSport.SelectedValue = sportId.ToString();
#region Position Category Dropdown
// Bind values to Position Category dropdown list in edit mode ONLY if sportId is available
if
(sportId > 0)
{
RadComboBox ddlPosCats = item.FindControl(
"RadComboBoxPositionCategory"
)
as
RadComboBox;
SetPositionCategoryOptions(ddlPosCats, sportId);
if
(item.ItemIndex != -1)
{
int
postCatid = 0;
Int32.TryParse(item.OwnerTableView.DataKeyValues[item.ItemIndex][
"PositionCategoryId"
].ToString(),
out
postCatid);
ddlPosCats.SelectedValue = postCatid.ToString();
}
}
#endregion
}
#endregion
}
}
catch
(Exception ex)
{
StatusMessage.Text =
"Error: "
+ ex.Message;
e.Canceled =
true
;
}
}
protected
void
RadGrid1_UpdateCommand(
object
source, Telerik.Web.UI.GridCommandEventArgs e)
{
try
{
// Clear out status message
StatusMessage.Text = String.Empty;
// Get the GridEditableItem of the RadGrid
GridEditableItem editedItem = e.Item
as
GridEditableItem;
// Get the primary key value using the DataKeyValue
int
positionId = Convert.ToInt32(editedItem.OwnerTableView.DataKeyValues[editedItem.ItemIndex][
"PositionId"
]);
string
positionName = (editedItem.FindControl(
"txtPositionName"
)
as
TextBox).Text;
int
sportId = Convert.ToInt32((editedItem.FindControl(
"RadComboBoxSport"
)
as
RadComboBox).SelectedValue);
int
posCatId = Convert.ToInt32((editedItem.FindControl(
"RadComboBoxPositionCategory"
)
as
RadComboBox).SelectedValue);
// Update value in table
if
(positionId > 0 && !String.IsNullOrEmpty(positionName) && sportId > 0 && posCatId > 0)
{
if
(!PositionBuilder.Update(positionId, positionName, posCatId, sportId, DateTime.UtcNow, Page.UserId))
{
StatusMessage.Text =
"Unable to update value. Please try again."
;
e.Canceled =
true
;
}
else
{
StatusMessage.Text =
"Successfully updated value!"
;
}
}
// Redraw grid
RadGrid1.Rebind();
}
catch
(Exception ex)
{
StatusMessage.Text =
"Unable to update record. Reason: "
+ ex.Message;
e.Canceled =
true
;
}
}
protected
void
RadGrid1_InsertCommand(
object
source, Telerik.Web.UI.GridCommandEventArgs e)
{
try
{
// Clear out status message
StatusMessage.Text = String.Empty;
GridEditFormInsertItem insertedItem = (GridEditFormInsertItem)e.Item;
string
positionName = (insertedItem.FindControl(
"txtPositionName"
)
as
TextBox).Text;
int
sportId = Convert.ToInt32((insertedItem.FindControl(
"RadComboBoxSport"
)
as
RadComboBox).SelectedValue);
int
posCatId = Convert.ToInt32((insertedItem.FindControl(
"RadComboBoxPositionCategory"
)
as
RadComboBox).SelectedValue);
if
(!String.IsNullOrEmpty(positionName) && sportId > 0 && posCatId > 0)
{
Position newPos = PositionBuilder.Add(positionName, posCatId, sportId, DateTime.Now, Page.UserId, DateTime.Now, Page.UserId);
if
(newPos.PositionId <= 0)
{
StatusMessage.Text =
"Unable to insert record. Please try again."
;
e.Canceled =
true
;
}
else
{
StatusMessage.Text =
"Successfully inserted record!"
;
}
}
}
catch
(Exception ex)
{
StatusMessage.Text =
"Unable to insert record. Reason: "
+ ex.Message;
e.Canceled =
true
;
}
}
protected
void
RadGrid1_DeleteCommand(
object
source, Telerik.Web.UI.GridCommandEventArgs e)
{
try
{
int
positionId = Convert.ToInt32(e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex][
"PositionId"
]);
//TODO: SOFT DELETE
}
catch
(Exception ex)
{
StatusMessage.Text =
"Unable to delete record. Reason: "
+ ex.Message;
e.Canceled =
true
;
}
}
#endregion
#region ComboBox
protected
void
RadComboBoxPositionCategory_ItemsRequested(
object
source, Telerik.Web.UI.RadComboBoxItemsRequestedEventArgs e)
{
try
{
//e.Text returns the value of the text parameter set on the client-side
RadComboBox combo = (RadComboBox)source;
combo.Items.Clear();
int
sportId = Convert.ToInt32(e.Text);
SetPositionCategoryOptions(combo, sportId);
}
catch
{
// Do nothing
}
}
#endregion
#region Dropdown Helpers
public
void
SetSportOptions(RadComboBox comboBox)
{
RadComboBoxItemCollection items =
new
RadComboBoxItemCollection(comboBox);
comboBox.Items.Add(
new
RadComboBoxItem(
"Select..."
, 0.ToString()));
try
{
SportCollection sports = SportBuilder.RetrieveList(String.Empty,
"Name ASC"
);
foreach
(Sport sport
in
sports)
{
comboBox.Items.Add(
new
RadComboBoxItem(sport.Name, sport.SportId.ToString()));
}
}
catch
{
// Do nothing
}
}
private
void
SetPositionCategoryOptions(RadComboBox comboBox,
int
sportId)
{
RadComboBoxItemCollection items =
new
RadComboBoxItemCollection(comboBox);
comboBox.Items.Add(
new
RadComboBoxItem(
"Select..."
, 0.ToString()));
comboBox.SelectedValue = 0.ToString();
try
{
PositionCategoryCollection posCats = PositionCategoryBuilder.RetrieveList(
String.Format(
"SportId={0}"
,sportId),
"CategoryName ASC"
);
foreach
(PositionCategory cat
in
posCats)
{
comboBox.Items.Add(
new
RadComboBoxItem(cat.CategoryName, cat.PositionCategoryId.ToString()));
}
}
catch
{
// Do nothing
}
}
#endregion
<
telerik:RadAjaxPanel
ID
=
"RadAjaxPanel1"
runat
=
"server"
height
=
"200px"
width
=
"95%"
>
<
telerik:RadComboBox
ID
=
"RadComboSearch"
Runat
=
"server"
AutoPostBack
=
"True"
EmptyMessage
=
"Type your search query here;"
Height
=
"98%"
ShowDropDownOnTextboxClick
=
"True"
ShowMoreResultsBox
=
"True"
Text
=
"Enter Search Criteria"
Width
=
"100%"
AllowCustomText
=
"True"
EnableVirtualScrolling
=
"True"
MarkFirstMatch
=
"True"
DataSourceID
=
"MyWebServices"
DataValueField
=
"StringResult"
DataTextField
=
"StringResult"
EnableAutomaticLoadOnDemand
=
"True"
ItemsPerRequest
=
"10"
>
</
telerik:RadComboBox
>
<
asp:ObjectDataSource
ID
=
"MyWebServices"
runat
=
"server"
SelectMethod
=
"SearchBoxResult"
TypeName
=
"NVSS_Manual.Lookup"
>
<
SelectParameters
>
<
asp:ControlParameter
ControlID
=
"RadComboSearch"
Name
=
"SearchString"
PropertyName
=
"Text"
Type
=
"String"
/>
</
SelectParameters
>
</
asp:ObjectDataSource
>
</
telerik:RadAjaxPanel
>
The data provider is a method on the page that calls a web service and converts the dataset to a datatable
public DataTable SearchBoxResult(string SearchString)
{
DataTable ReturnValue = null;
NVSS_ManualWebService.NVSS_Manual_WebService ws = new NVSS_ManualWebService.NVSS_Manual_WebService();
DataSet ds =ws.Search_BoxResult();
ReturnValue = ds.Tables[0];
return ReturnValue;
}
...
[WebMethod]
public DataSet Search_BoxResult(
)
{
DataSet ds = new DataSet();
DataTable dt = new DataTable();
DataColumn dc=new DataColumn("StringResult", Type.GetType("System.String"));
dt.Columns.Add(dc);
ds.Tables.Add(dt);
dt.Rows.Add("Appendicitus");
dt.Rows.Add("aaa1");
dt.Rows.Add("aaa3");
dt.Rows.Add("aaa2");
return ds;
}
...
protected void Load_ManualWithFoundContent(string SearchResult)
{
WebServiceProxy wsp = new WebServiceProxy();
DataSet ManualsWithSearchResults = wsp.GetServicesHandle.Search_ManualTitlesResult(SearchResult);
DataTable dt = ManualsWithSearchResults.Tables[0];
DataRowCollection drc = dt.Rows;
RadListBoxItemCollection rlbic = RadList_ManualsWithFoundContent.Items;
int i = 0;
foreach (DataRow dr in drc)
{
RadListBoxItem rlbi = new RadListBoxItem(dr["ManualName"].ToString(), dr["pKey"].ToString());
rlbi.BackColor = i++ %2 ==0 ? Color.WhiteSmoke : Color.White;
rlbic.Add(rlbi);
}
}
function RadList_ManualsWithFoundContent_OnClientMouseOver(sender, evenArgs) {
...???set item color???...
}