or
protected
void
gridCPDiag_SortCommand(
object
source, GridSortCommandEventArgs e)
{
GridTableView tableView = e.Item.OwnerTableView;
if
(e.Item.OwnerTableView.Name ==
"Detail2"
&& e.SortExpression ==
"VisitFrequency"
)
{
e.Canceled =
true
;
GridSortExpression expression =
new
GridSortExpression();
expression.FieldName =
"VisitFrequency"
;
if
(tableView.SortExpressions.Count == 0 || tableView.SortExpressions[0].FieldName !=
"VisitFrequency"
)
{
expression.SortOrder = GridSortOrder.Descending;
}
else
if
(tableView.SortExpressions[0].SortOrder == GridSortOrder.Descending)
{
expression.SortOrder = GridSortOrder.Ascending;
}
else
if
(tableView.SortExpressions[0].SortOrder == GridSortOrder.Ascending)
{
expression.SortOrder = GridSortOrder.None;
}
tableView.SortExpressions.AddSortExpression(expression);
tableView.Rebind();
}
}
Hi,
I have opened update form after save then dropdown selected value is not showing in the UI.
<
telerik:RadGrid
ID
=
"AttachmentGrid"
GridLines
=
"None"
runat
=
"server"
AllowAutomaticDeletes
=
"True"
AllowAutomaticInserts
=
"True"
AllowAutomaticUpdates
=
"False"
AllowPaging
=
"True"
DataSourceID
=
"AttachmentDataSource"
Skin
=
"Metro"
AllowSorting
=
"True"
AutoGenerateDeleteColumn
=
"False"
OnItemCommand
=
"AttachmentGrid_ItemCommand"
>
<
MasterTableView
Width
=
"100%"
DataKeyNames
=
"id"
DataSourceID
=
"AttachmentDataSource"
HorizontalAlign
=
"NotSet"
AutoGenerateColumns
=
"False"
EditMode
=
"PopUp"
>
<
telerik:GridTemplateColumn
UniqueName
=
"InitiatorName"
Groupable
=
"False"
HeaderText
=
"Which entity or company did you receive this file from?"
DataField
=
"InitiatorName"
Visible
=
"false"
>
<
headerstyle
width
=
"1000px"
/>
<
itemtemplate
>
<%#DataBinder.Eval(Container.DataItem, "InitiatorName")%>
</
itemtemplate
>
<
edititemtemplate
>
<
asp:DropDownList
ID
=
"InitiatorName"
runat
=
"server"
CssClass
=
"textbox"
SelectedValue='<%# Bind("InitiatorName") %>'
DataSourceID="CompanyNameDataSource" DataTextField="InitiatorName" Width="300px"
DataValueField="InitiatorName" OnSelectedIndexChanged="InitiatorName_SelectedIndexChanged"
AutoPostBack="true">
</
asp:DropDownList
>
<
asp:RequiredFieldValidator
ID
=
"ReqInitiatorName"
runat
=
"server"
ControlToValidate
=
"InitiatorName"
ErrorMessage
=
"Please Select a Company Name"
Display
=
"Dynamic"
SetFocusOnError
=
"true"
/>
</
edititemtemplate
>
<
asp:SqlDataSource
ID
=
"CompanyNameDataSource"
runat
=
"server"
ConnectionString="<%$ ConnectionStrings:TaskManagementConnectionString %>"
SelectCommand="select distinct InitiatorName from t_TaskMaster where (InitiatorName<>'' and InitiatorName is not null )union all select '' order by InitiatorName asc">
</
asp:SqlDataSource
>
<
asp:SqlDataSource
ID
=
"AttachmentDataSource"
runat
=
"server"
ConnectionString="<%$ ConnectionStrings:TaskManagementConnectionString %>"
SelectCommand="SELECT id,refid,[filename],[Description],[Content],upper(Status) as [Status],DateUpdated,UpdatedBy, isnull(FileCategory,'') as FileCategory ,isnull(FileMainCategory,'') as FileMainCategory,isnull([MainClassofInsurance],'') as [MainClassofInsurance],isnull([InitiatorName],'') as [InitiatorName],emailrefid FROM [t_Attachments] WHERE (FileCategory is null or FileCategory='') and (([UpdatedBy] = @UpdatedBy)) AND [Status] <>'DELETED' and refid<>'0'"
DeleteCommand="delete from t_Attachments where id=@id ">
<
SelectParameters
>
<
asp:SessionParameter
Name
=
"UpdatedBy"
SessionField
=
"UserName"
Type
=
"String"
/>
</
SelectParameters
>
</
asp:SqlDataSource
>
PLease help me on this why it's not showing selected value even SelectedValue='<%# Bind("InitiatorName") %>' is there ?
<
telerik:RadAjaxManager
id
=
"RadAjaxManager1"
runat
=
"server"
>
<
AjaxSettings
>
<
telerik:AjaxSetting
AjaxControlID
=
"RadGrid1"
>
<
UpdatedControls
>
<
telerik:AjaxUpdatedControl
ControlID
=
"RadGrid1"
/>
</
UpdatedControls
>
</
telerik:AjaxSetting
>
</
AjaxSettings
>
<
ClientEvents
OnRequestStart
=
"RequestStart"
OnResponseEnd
=
"ResponseEnd"
/>
</
telerik:RadAjaxManager
>
<
telerik:RadAjaxLoadingPanel
ID
=
"RadAjaxLoadingPanel1"
runat
=
"server"
Skin
=
"Default"
>
</
telerik:RadAjaxLoadingPanel
>
<
asp:Panel
ID
=
"Panel1"
runat
=
"server"
>
<
div
id
=
"dashtabs-comments"
class
=
"box-content no-padding"
>
<
telerik:Radgrid
id
=
"RadGrid1"
runat
=
"server"
allowmultirowselection
=
"False"
allowpaging
=
"True"
allowsorting
=
"True"
gridlines
=
"None"
pagesize
=
"25"
showstatusbar
=
"True"
autogeneratecolumns
=
"False"
CellSpacing
=
"0"
>
<
ClientSettings
>
<
DataBinding
Location
=
"manageUsers.aspx"
SelectMethod
=
"GetDataAndCount"
/>
<
ClientEvents
OnGridCreated
=
"AddAllFilterExpressions"
OnDataBinding
=
"RadGrid1_DataBinding"
OnRowDataBound
=
"OnGridRowDataBound"
/>
</
ClientSettings
>
<
HeaderContextMenu
EnableTheming
=
"True"
>
<
CollapseAnimation
Duration
=
"200"
Type
=
"OutQuint"
/>
</
HeaderContextMenu
>
<
MasterTableView
ClientDataKeyNames
=
"UserId"
TableLayout
=
"Fixed"
>
<
Columns
>
<
telerik:GridBoundColumn
DataField
=
"FirstName"
UniqueName
=
"FirstName"
HeaderText
=
"First Name"
HeaderStyle-Width
=
"15%"
/>
<
telerik:GridBoundColumn
DataField
=
"LastName"
UniqueName
=
"LastName"
HeaderText
=
"Last Name"
HeaderStyle-Width
=
"15%"
/>
<
telerik:GridBoundColumn
DataField
=
"Email"
UniqueName
=
"Email"
HeaderText
=
"Email"
HeaderStyle-Width
=
"15%"
/>
<
telerik:GridBoundColumn
DataField
=
"PhoneNumber"
UniqueName
=
"PhoneNumber"
HeaderText
=
"Phone"
HeaderStyle-Width
=
"10%"
/>
</
Columns
>
<
RowIndicatorColumn
>
<
HeaderStyle
Width
=
"20px"
/>
</
RowIndicatorColumn
>
<
ExpandCollapseColumn
>
<
HeaderStyle
Width
=
"20px"
/>
</
ExpandCollapseColumn
>
<
EditFormSettings
>
<
EditColumn
FilterControlAltText
=
"Filter EditCommandColumn column"
></
EditColumn
>
</
EditFormSettings
>
</
MasterTableView
>
<
ClientSettings
>
<
Selecting
AllowRowSelect
=
"True"
/>
</
ClientSettings
>
<
FilterMenu
EnableTheming
=
"True"
>
<
CollapseAnimation
Duration
=
"200"
Type
=
"OutQuint"
/>
</
FilterMenu
>
<
PagerStyle
Mode
=
"NextPrevNumericAndAdvanced"
/>
</
telerik:Radgrid
>
</
div
>
</
asp:Panel
>
<script type=
"text/javascript"
>
function
RadGrid1_DataBinding(sender, args) {
// get data source location, method name and arguments
var
dataSourceLocation = args.get_location();
var
selectMethodName = args.get_methodName();
var
methodArguments = args.get_methodArguments();
// set data source location and method name
args.set_location(dataSourceLocation);
args.set_methodName(selectMethodName);
var
startRowIndexParameterName = sender.ClientSettings.DataBinding.StartRowIndexParameterName;
var
maximumRowsParameterName = sender.ClientSettings.DataBinding.MaximumRowsParameterName;
var
sortParameterName = sender.ClientSettings.DataBinding.SortParameterName;
var
filterParameterName = sender.ClientSettings.DataBinding.FilterParameterName;
}
function
AddFilter(name, value) {
var
grid = $find(
"<%= RadGrid1.ClientID %>"
);
var
filterExpression =
new
Telerik.Web.UI.GridFilterExpression();
var
column = grid.get_masterTableView().getColumnByUniqueName(
"linkColumn"
);
var
filterFunction = Telerik.Web.UI.GridFilterFunction.Contains;
column.set_filterFunction(filterFunction);
filterExpression.set_fieldName(name);
filterExpression.set_fieldValue(value);
filterExpression.set_filterFunction(filterFunction);
filterExpression.set_columnUniqueName(
"name"
);
grid.get_masterTableView()._updateFilterControlValue(value,
"name"
, filterFunction);
grid.get_masterTableView()._filterExpressions.add(filterExpression);
}
function
AddAllFilterExpressions(sender, args) {
AddFilter(
"aname"
, document.getElementById(
'<%= tAccountName.ClientID %>'
).value);
AddFilter(
"fname"
, document.getElementById(
'<%= tFirstName.ClientID %>'
).value);
AddFilter(
"lname"
, document.getElementById(
'<%= tLastName.ClientID %>'
).value);
AddFilter(
"email"
, document.getElementById(
'<%= tEmail.ClientID %>'
).value);
AddFilter(
"uname"
, document.getElementById(
'<%= tUserName.ClientID %>'
).value);
}
var
currentLoadingPanel =
null
;
var
currentUpdatedControl =
"<%= Panel1.ClientID %>"
;
function
RequestStart(sender, args) {
currentLoadingPanel = $find(
"<%= RadAjaxLoadingPanel1.ClientID %>"
);
//show the loading panel over the updated control
currentLoadingPanel.show(currentUpdatedControl);
}
function
ResponseEnd() {
//hide the loading panel and clean up the global variables
if
(currentLoadingPanel !=
null
)
currentLoadingPanel.hide(currentUpdatedControl);
currentUpdatedControl =
null
;
currentLoadingPanel =
null
;
}
</script>
<
ul
class
=
"rsResourceControls"
>
<
li
>
<!-- Resource controls should follow the convention Res[Resource Name] for ID -->
<
scheduler:ResourceControl
runat
=
"server"
ID
=
"ResourceTypeID"
Type
=
"ResourceType"
Label
=
"Resource type:"
Skin='<%# Owner.Skin %>' />
</
li
>
<!-- Optionally add more ResourceControl instances here -->
</
ul
>
[Bindable(BindableSupport.Yes, BindingDirection.TwoWay)]
public
object
ResourceType
{
get
{
return
ResourceTypeID.Value;
}
set
{
ResourceTypeID.Value = value;
}
}
<ul
class
=
"rsResourceControls"
>
<li>
<!-- Resource controls should follow the convention Res[Resource Name]
for
ID -->
<scheduler:ResourceControl runat=
"server"
ID=
"ResourceType"
Type=
"ResourceType"
Label=
"Resource type:"
Skin=
'<%# Owner.Skin %>'
/>
</li>
<!-- Optionally add more ResourceControl instances here -->
</ul>
[Bindable(BindableSupport.Yes, BindingDirection.TwoWay)]
public
object
ResourceTypeID
{
get
{
return
ResourceType.Value;
}
set
{
ResourceType.Value = value;
}
}