SQL Server :: Sorting Data By Called Title?
Jan 12, 2011
I'm using Sqlreader to get some information from a database table. Right now I have it looping through a while loop, and adding in the appropriate information in to an asp table contol. I'm not haveing any difficulty with that, what I am having problems with is sorting the data. I just want it to sort it by a field called title. I tried putting an ORDER BY statement into my SQL command, but it throws an error saying it cannot sort a text field. So the only thing I can think of is instead of adding the data right from the sqlreader to the table control is that I first put it into an array, sort the array, and then add it to the table control. It seems like an ineffieint way of doing it. Is there a better way of sorting this stuff or is there a way to get the database to do it for me like with the ORDER BY command?
View 5 Replies
Similar Messages:
Apr 12, 2010
I have been researching this issue for a couple of days and have found a lot written about it, but none of what I have found has fixed the problem I am having.
I work for a school system, and my principals are wanting to take a list of the staff members at their school and create staff lists for different activities they perform. I thought I would load the staff into Gridveiw1, and when they select a record have it move over into Gridview2 and "delete" from Gridview1.
I am loading my full staff into a datatable (SQL Server backend), and setting this datatable as my gridview1 datasource. At this point, it loads great, and cosmetically speaking sorts and pages fine. The problem occurs in the codebehind after a Sort or Page change has occurred -- when I select a record and move it over into Gridview2, it is moving the original record that was at that postion on Page 1 instead of the sorted or "new page" record.
So if the initial list comes in as:
Teacher 1
Teacher 2
Teacher 3
The sort button is hit so that the list now starts out like:
Teacher 7
Teacher 13
Teacher 5
If they select "Teacher 13" to be moved over after the sort, instead it is still moving over "Teacher 2" -- the initial teacher in that index before the sort.
The Gridview setup on my aspx page looks like this:
[Code]....
My codebehind:
[Code]....
View 2 Replies
Jul 18, 2010
Moderators Note: THIS ISSUE IS BIG FOR ME AND EVEN IF POSSIBLE, GET THE REPLY FROM THE DESIGNER OF GRIDVIEW. I have been looking for him for long. I am really fed up with reviewing a good lot of web pages on how we can possibly customize the gridview to enable sorting and paging. So many sites have listed out a lot of information and so many guidances. But the problem is that one works out fine and the other is a burden. I really feel bad about being given the job of customizing this kind of a gridview which has no user friendly approach to it. Also, this control is rendered without the pager links inside the <tfoot> tag. I have tried the Pear Pager in php. It is that good and easy to use and compared to that, the gridview in asp.net is the worst ever control i have ever tried so far.
1. i can use the images to indicate the sorting direction
2. I can have the custom pager like
[code]
<<Previous 1 2 3 .. 7 Next >>.
[/code]
When i click the next when i am viewing the page at 3 , the pager links should change as
[code]
<<Previous 2 3 4 .. 7 Next >>
[/code]
Kindly look into this type of requirement and firstly tell me whether this is possible with the gridview control. I would like this request even to be escalated to the designers of the gridview control also, so that Microsoft comes out with a reply THAT WORKS and not the kind of stuff like surfing through a lot of links and pages and finally wasting a lot of days precious time and still breaking the head with this useless control. I have spent a lot of time in searching for a perfect way. Not writing a code that is non-standard. I am really serious b'cos I have spent weeks in customizing this control. If I dont get a solid reply atleast now, I am going to generate all the output by HTML content by custom coding.
View 7 Replies
Apr 14, 2010
I want to use a gridview with sorting and paging to display data from an SQL server, the query uses 3 joins and the full text search containstable. The from part of the query uses all 3 tables in the join.What is the best way to do this? I can think of a stored procedure, SQL directly in the SQLDataSource and creating a view in the database.I want good performance and would like to leverage the automatic sorting and paging features of the gridview as much as possible.
Edit:About size, I suspect very few records, total about 1000 and a query would typical result in no more than 100 records and most times much less.
View 4 Replies
Nov 15, 2010
I have a weird design. I have page called A, it has control called C1 which has a control called C1-1 which has a control called C-1-1-1. C-1-1-1 is inside a modal popup extender. Whenever their is a postback, the C-1-1-1 's Pre_Render is called twice, first with the correct values and parameters which seem right. And second with all values seemingly reset (sounds like a new object construction).
View 2 Replies
Dec 9, 2010
How to Display Icon IN title bar of Browser with title?
View 7 Replies
Mar 29, 2011
In my application I have the following message:Object reference not set to an instance of an object.
@Html.DropDownList("Title",ViewData["PersonTitle"] as SelectList, Model.Person.Title)
The dropdownlist contains simple strings (person titles). When you select a title, that title should be returned to my model. Controller code:
ViewData["PersonTitle"] = new SelectList(new[] { "Dhr.", "Mevr." });
Why is this not working ? Edit: The purpose is to change
@Html.EditorFor(model => model.Person.Title)
into something like this
@Html.DropDownList("Title",ViewData["PersonTitle"] as SelectList, Model.Person.Title)
View 2 Replies
Sep 21, 2010
Basically I have a table as follows:
Page Title ¦ DateTime
Home ¦ 20/09/2010 17:25:01
Home ¦ 20/09/2010 16:01:16
Home ¦ 20/09/2010 17:24:01
About Us ¦ 06/09/2010 17:27:01
Home ¦ 03/09/2010 14:25:01
SiteMap ¦ 21/09/2010 17:21:01
I want to get the unique page title but latest date, therefore query result would be:
SiteMap
Home
About Us
View 3 Replies
Oct 12, 2010
I create a webcontrol (DefectsList as a gridview) with an icon that call an httphandler to open an other webcontrol (DefectEditor as an editor) but the CreateChildControls of the editor is not called!!
see the details below of DefectsList:
[Code]....
and the javascript:
[Code]....
see the details below of DefectEditor:
[Code]....
Why the CreateChildControls is not called, I think is due to the HttpHandler? so how to do?
View 6 Replies
Jan 28, 2010
I run a site with decent traffic (~100,000 page views per day) and sporadically the site has been brought to its knees due to SQL Server timeout errors.When I run SQL Profiler, I see a command getting called hundreds of times a second like this:
exec dbo.TempGetStateItemExclusive3 @id=N'ilooyuja4bnzodienj3idpni4ed2081b',...
We use SQL Server to store ASP.NET session state. The above is the stored procedure called to grab the session state for a given session. It seems to be looping, asking for the same 2 or 3 sessions over and over. I found a promising looking hot fix that seems to address this exact situation, but it doesn't seem to have solved the problem for us. (I'm assuming this hotfix is included in the most recent .NET service pack, because it doesn't look like you can install it directly anymore). I added that registry key manually, but we still see the looping stored procedure calls like above (requesting the same session much more often than every 500ms) I haven't been able to recreate this on a development machine. When two requests are made for the same session ID, it seems to block correctly, and even try to hit SQL until the first page releases the session.
View 3 Replies
Mar 29, 2011
I've modified an existing strored procedure. It originally had one ouput parameter in the stored proc and it was set up as follows in the c# code that called it:
cmd.Parameters.Add("@Var1Param", SqlDbType.BigInt);
if (Var1 == 0)
cmd.Parameters["@Var1"].Value = DBNull.Value;
else
cmd.Parameters["@Var"].Value = Var1;
cmd.Parameters["@Var1"].Direction = ParameterDirection.InputOutput;
cmd.ExecuteNonQuery();
// Get Var1
Var1= dataMorph.ToInt64(cmd.Parameters["@Var1"].Value.ToString());
Just to clarify, this parameter was declared as OUTPUT in the stored proc but as inputoutput in the C# code. This worked fine. I have added another parameter to the same stored procedure and I want to retrieve both from the C# code. The C# code now is as follows:.................................
View 3 Replies
Mar 22, 2011
I have an ASP.NET (3.5) web page which calls a few web methods (SOAP based) using jQuery's .ajax method. The web methods implement 'ScriptMethod' attribute and return JSON data. The web service file (asmx) is local to the same project.
I noticed these web methods execute synchronously on the server which means they run sequentially and affect performance negatively, some methods are waiting, when some of them are slow.
I read this article and I am not sure if I understand that WebMethods which implement Scriptmethod can run synchronously only (they implement IHttpHandler not IHttpAsyncHandler).
If this is true, I might have to change the design. I am looking for other designs, maybe like using WCF, where the browser can call webmethods using JavaScript and the web methods run asynchronously on the server.
View 2 Replies
Jan 8, 2011
I have a column TimePeriod with values in mmm-yyyy format. ex. Jan-2010, Apr-2010,Nov-2010, Dec-2010, Jan-2011
How can I wirte query so result will be in order by Jan-2010, Feb-2010,..... Jan-2011.
I tried to cast, convert but i couldnt figured it out. I did googling... can't find solution.
View 3 Replies
Dec 17, 2010
I'm somewhat new to aps.net and am not sure how to come up with a technique for acheiving the following results.I think a GridView might do the trick, but am unsure how to manage the sorting/grouping aspect. Here's what I need to do:
[code]...
View 4 Replies
May 12, 2010
I have developed a web application which contains aspdotnet treeview control. In this treeview control has binded with some database value.. that controls has one parent node and more than one child nodes for each parent node.
my problem is here, when the user clicks the parent node, I need to fire a javascript onclick function before the server side event(SelectedNodeChanged) called..
If I provide javascript to the parnet node when it is binding, then I could not fire the server side event(SelectedNodeChanged).
How to provide onclick javascript event for parent node in treeview control even the parent node has SelectedNodeChanged event.
View 6 Replies
Mar 1, 2011
When it comes to sort some data, we have two option to sort the data: first one is sort on SQL server with ORDER BY clause, and another is Client side sorting ,how i can choose one option over the other and why? which option is more efficient? with sorting? is there any sorting function with client side sorting? what is the adventage on client side sorting?
View 1 Replies
Dec 28, 2010
when I use 'RowNumber' = ROW_NUMBER() OVER(ORDER BY ColumnName) then due to orderby Column name consume 76% usage in execution plan . in such case what I have to do? I can see sorting taking much time in execution plan.
View 9 Replies
Feb 15, 2010
I have a simple site [URL]that I setup for my parents and other family member to share recipes on. The issue I have is that when I try to incorporate a google search the header is always RECIPE form from the dynamically driven site.
If page requested is [URL] in a SEO return I want it to have the title of the recipe to be Apple Sour Cream Crumble Pie not RECIPE FORM or RECIPE PRINT FULL FORM
How can I get this changed and also have metadata dynamically created to improve SEO returns?
View 1 Replies
Oct 25, 2010
When I click on my GridView header "End Time" all the rows which contain the string "N/A" disappear.
Here is my code:
[Code]....
Note: GetSortDirection returns "endTime ASC" or "endTime DESC" and save in ViewState:
[Code]....
Then I fill the DataAdapter and use the ViewState info to sort it:
[Code]....
View 2 Replies
May 31, 2012
How to put the title of the report on the page within this cluster of your code? Â
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
GridView_EngrDisp.RenderControl(hw);
[Code]....
I experimented with a couple of things and looked at MSDN on stringwrite/stringbuilder, etc before bothering you. Keep in mind I'm not talking about the gridview column headings; I'm talking about the report title before the gridview.Â
View 1 Replies
Mar 7, 2010
Im still a newbie in both the software and over here.. not quite sure where to put this topic
I have an unbound gridview.. which uses databind instead of sqldatasource..
the thing is how do I modify the title of the column name?
For example.. instead of
MemberID MemberName MemberAddress.... i want it to be like
ID Name Address..
Sample code:
cmdSelectService = new SqlCommand("SELECT JobPost.JobPostID, JobPost.JobPostInformation, JobSpecialization.JobSpecializationName,[code]....
View 1 Replies
Oct 18, 2012
How to add Title on top of all pages while printing gridview records...
View 1 Replies
Feb 14, 2014
I have a page which lists stores,malls of individual cities. I have used the list of cities in DropDownList. I have added dynamic title to page as like
Page.Title="Stores in"+DropDownList1.SelectedValue;
It works fine. But when I see that page in Google Search then its showing only one title like "Stores in Delhi". Here 'Delhi' is in the default selected value in DropDownList1. But as I have many cities in that DropDownList1, I want to show each value of DropDownList1 to be appear in search result as title according to search query. For example if user types search query "Stores in Jaipur" then search result should show result with this title "Stores in Jaipur" Remember that Dynamic title is working fine but question is that "How to show is in search result"
View 1 Replies
Mar 13, 2013
I used iTextSharp to convert my gridview into a pdf document however i want to have my logo on the top right hand corner of every pdf page along with a static title word at the bottom left of everypage generated.
View 1 Replies
Dec 13, 2010
reportdaywise.aspx
asp:GridView ID
BorderWidth="3px" CellPadding="4"
tyle" HeaderStyle-BackColor="#346BAF"
HeaderStyle-ForeColor="white" HorizontalAlign="Center"
onrowcreated="grdattendncereport_RowCreated"
[code]...
View 3 Replies