Similar to F12 hotkey from code, I would like to go to the method that is used in the markup, eg.
<asp:ObjectDataSource ID="dsADDOCs" runat="server" SelectMethod="DataSet_SelectForProject"
TypeName="DataLogic.tADDOCList" OnSelecting="dsADDOCs_Selecting">
<SelectParameters>
<asp:Parameter DefaultValue="" Name="iORDRID" Type="Int32" />
<asp:Parameter DefaultValue="" Name="iAccesses" ConvertEmptyStringToNull="true" Type="String" />
<asp:Parameter Name="iTracer" Type="String" ConvertEmptyStringToNull="true" DefaultValue="" />
</SelectParameters>
</asp:ObjectDataSource>
So here if I would ctrl+click or F12 on dsADDOCs_Selecting, than it would go to the codebehind to the dsADDOCs_Selecting method, or when I do the same on DataSet_SelectForProject, than it would open DataSet_SelectForProject method in DataLogic.tADDOCList
Is there an option, plugin or anything to do this? It would be really helpful.
Related
In my ASP.NET web forms I find that the ObjectDataSource won't update/refresh when the SelectParameter values do not change.
How do I force refresh an ObjectDataSource regardless of whether or not the parameter values change?
Example code:
<asp:ObjectDataSource ID="odsUserSearchResults" runat="server"
SelectMethod="GetData" EnablePaging="false"
TypeName="MySolution.ObjectDataSources.Users">
<SelectParameters>
<asp:ControlParameter Name="name" ControlID="txtName" PropertyName="Text" Type="String" />
<asp:ControlParameter Name="statusId" ControlID="ddlStatus" PropertyName="SelectedValue" Type="Int32" />
</SelectParameters>
</asp:ObjectDataSource>
You need to disable the object data source view state by setting the EnableViewState property to false, like so:
<asp:ObjectDataSource ID="odsUserSearchResults" EnableViewState="false" runat="server"
SelectMethod="GetData" EnablePaging="false"
TypeName="MySolution.ObjectDataSources.Users">
<SelectParameters>
<asp:ControlParameter Name="name" ControlID="txtName" PropertyName="Text" Type="String" />
<asp:ControlParameter Name="statusId" ControlID="ddlStatus" PropertyName="SelectedValue" Type="Int32" />
</SelectParameters>
</asp:ObjectDataSource>
I currently have a table of data which is ordered in ID order, but i want the list to be ordered in descending order. This i am sure is a simple question but i just can not figure out how to do it.
Here is the ObjectDataSource etc. I am just not sure where to change the code...
Thanks
<asp:ObjectDataSource
ID="odsTours"
runat="server"
SelectMethod="GetFiltered"
TypeName="blive.Shop.Tour"
SortParameterName="sortExpression">
<SelectParameters>
<asp:Parameter
Name="isActive"
ConvertEmptyStringToNull="true"
DefaultValue="" />
<asp:Parameter
Name="isInThePast"
ConvertEmptyStringToNull="true"
DefaultValue="" />
</SelectParameters>
</asp:ObjectDataSource>
<asp:ObjectDataSource
ID="odsBookings"
runat="server"
SelectMethod="GetFiltered"
TypeName="blive.Shop.Booking"
SortParameterName="sortExpression">
<SelectParameters>
<asp:ControlParameter
ControlID="ddlTourFilter"
PropertyName="SelectedValue"
Name="tourId"
Type="Int32"
ConvertEmptyStringToNull="true" />
<asp:Parameter
Name="username"
ConvertEmptyStringToNull="true"
DefaultValue="" />
</SelectParameters>
</asp:ObjectDataSource>
It should be done in the select method of the object data source.
In your case it should be in
GetFiltered method.
You can apply the order by in this method.
When working with ObjectDataSource I have following select:
<asp:DropDownList runat="server" SelectedValue='<%# Bind("InceptionCycle.ID") %>' ID="InceptionCycle"
DataSourceID="odsAllCycles" DataTextField="CycleName" DataValueField="ID" AppendDataBoundItems="true">
<asp:ListItem Text="Choose..." Value=""></asp:ListItem>
</asp:DropDownList>
and ObjectDataSource configured with UpdateMethod and InsertMethod. However insert/update methods have parameters with InceptionCycle name (because InceptionCycle.ID is not valid identifier).
Is there a way to instruct ObjectDataSource to take InceptionCycle.ID form parameter and place in as InceptionCycle method parameter?
Here's full ObjectDataSource code:
<asp:ObjectDataSource ID="ods" runat="server" TypeName="Sources.DomainSource"
SelectMethod="FindById" InsertMethod="Add" UpdateMethod="Update"
OnInserted="ods_Inserted" OnUpdated="ods_Updated">
<SelectParameters>
<asp:QueryStringParameter Name="id" QueryStringField="id" />
</SelectParameters>
<InsertParameters>
<asp:Parameter ConvertEmptyStringToNull="true" Name="ShortTitle" />
<asp:Parameter ConvertEmptyStringToNull="true" Name="WMRId" />
<asp:Parameter ConvertEmptyStringToNull="true" Name="MDSId" />
<asp:Parameter ConvertEmptyStringToNull="true" Name="Status" />
</InsertParameters>
<UpdateParameters>
<asp:QueryStringParameter Name="id" QueryStringField="id" />
<asp:Parameter ConvertEmptyStringToNull="true" Name="ShortTitle" />
<asp:Parameter ConvertEmptyStringToNull="true" Name="WMRId" />
<asp:Parameter ConvertEmptyStringToNull="true" Name="MDSId" />
<asp:Parameter ConvertEmptyStringToNull="true" Name="Status" />
</UpdateParameters>
</asp:ObjectDataSource>
You can only use the Bind syntax with a top level property - it doesn't support nested properties (VS 2012 will, though).
So, you should create a new property on your data source like below and bind the SelectedValue to this new property instead
public string InceptionCycleID
{
get
{
return InceptionCycle.ID;
}
set
{
InceptionCycle.ID = value;
}
}
Issue: I have 2 datasources declared on my .aspx file as shown below:
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server" DeleteMethod="UsuarioDelete" SelectMethod="SelectMyAllNotME_Data" TypeName="BLLayer.Usuarios" OnInserted="ObjectDataSource_Inserted">
<DeleteParameters>
<asp:ControlParameter ControlID="ConfirmDialogBox1" Name="id_usuario" PropertyName="Aceptar_CommandName" Type="Int32" />
</DeleteParameters>
<SelectParameters>
<asp:SessionParameter DefaultValue="1" Name="id_usuario" SessionField="id_usuario" Type="Int32" />
<asp:SessionParameter DefaultValue="1" Name="id_pais" SessionField="id_pais" Type="Int32" />
</SelectParameters>
</asp:ObjectDataSource>
<asp:ObjectDataSource ID="ObjectDataSource2" runat="server" DeleteMethod="UsuarioDelete" SelectMethod="SelectMyAllNotME_Data" TypeName="BLLayer.Usuarios" OnInserted="ObjectDataSource_Inserted">
<DeleteParameters>
<asp:ControlParameter ControlID="ConfirmDialogBox1" Name="id_usuario" PropertyName="Aceptar_CommandName" Type="Int32" />
</DeleteParameters>
<SelectParameters>
<asp:QueryStringParameter DefaultValue="0" Name="id_emp" QueryStringField="id_emp" Type="Int32" />
</SelectParameters>
</asp:ObjectDataSource>
The method "SelectMyAllNotME_Data" is an overloaded method that in one he receives 2 values and in the other just one value, it is used to filter the information.
What I want to do is than in my onLoadPage method is something like this:
if (Request.QueryString["id_emp"] != null)
{
GridViewUsers.DataSource = ObjectDataSource2.SelectMethod;
GridViewUsers.DataMember = ObjectDataSource2.SelectMethod;
}
else
{
GridViewUsers.DataSource = ObjectDataSource1.SelectMethod;
GridViewUsers.DataMember = ObjectDataSource1.SelectMethod;
}
}
I've already tried this, but it isn't working, can anyone help me please?
You should call
GridViewUsers.DataBind();
on the datasource in aspx just do
EnablePaging="true"
How to change to use like instead of = ?
([Card_no] = #Search)
Moreover, if i want to show all in default, this method force to user to type
something first. How to show all in default when using control parameter?
SelectCommand="SELECT [Serial_no], [Transaction_Date], [Card_no], [Company],[IsCredit], [Fee] FROM [CarPark] WHERE ([Card_no] = #Search) or ([Company] = #Search)"
UpdateCommand="UPDATE [CarPark] SET
Card_no=#Card_no,
Company=#Company,
IsCredit=#IsCredit,
Fee=#Fee
WHERE Serial_no=#Serial_no">
<UpdateParameters>
<asp:Parameter Name="Card_no" Type="String" />
<asp:Parameter Name="Company" Type="String" />
<asp:Parameter Name="IsCredit" Type="Boolean" />
<asp:Parameter Name="Fee" Type="Double" />
</UpdateParameters>
<SelectParameters>
<asp:ControlParameter ControlID="Search_TextBox" DefaultValue="" Name="Search"
PropertyName="Text" Type="String" />
</SelectParameters>
Try this:
Card_no like '%{0}%'
Or if you must use named parameters:
Card_no like '%'+#search +'%'