Forms Data Controls :: How To Code It Such That Sorting In Gridview1 Sort Gridview2 As Well
Mar 31, 2010
I have 2 Gridviews of the same structure and header. I want when user click hear of Gridview 1 for sorting, the same sorting applies to Gridview2 onclick.
I have a gridview1 with a Select column, which has a SqlDataSource that executes a Store Procedure.
I also have another gridview2, which also has its own SqlDataSource, but in this case, the Store Procedure has a parameter. This DataSource assigns as parameter the gridview1 control, and its PropertyName is SelectedValue. How can I load the gridview2 when gridview1 is clicked in the Select Column?
I have a dropdownlist (ddlList) in gridview1. I need to reference that ddlList as my ControlID for the parameter.
I tried to define gridview1.ddlList, but this did not work. Is there any way (non-codebehind) that I can use to reference a dropdownlist which resides in gridview1 from gridview2?
I have a default.aspx page which has two gridview controls i.e. Gridview1 [Displaying Order table] and Gridview2 [displaying OrderDetails table], when I am deleting a row in GridView1, GridView2 should also update its datasource because of referential integrity constraints.
Following is what I am trying to do in GridView2_Load event:
I have a page displays CRM data (with CrmService) in GridView. Everything run ok until I tried to sort out one field by default and I received the following exception: The GridView 'GridView1' fired event Sorting which wasn't handled. The reason I am using GridView to do the sorting because:
1) Cannot do it with SQL "ORDER BY" since date retrieval from CRM Web Service
2) Cannot use OrderExpression for QueryExpression from CRM because the column I want to sort is generated by my algorithm
GridView1.Sort("ColumnName" SortDirection.Descending); in Page_Load, or Button1_Sort(object sender, GridViewSortEventArgs e), they all trigger the above execption!
I also added the method to the following method to handle exception, but didn't work:
I have a Gridview, lets call it GVDistinctDate which displays Distinct Date in one column only. For example: I got 5 rows, and 1 column where the column only display distinct dates such as 02/04/2010 | 03/04/2010 | 04/04/2010 | 05/04/2010 | 06/04/2010 where obviously this dates come from a table in the database.
Now i want to take those dates in GVDistinctDate and assign it to another gridview, lets call it GVReport, as column Header Text. For this GVReport, the first column would be StudentID where a list of studentid will be displayed, and then starting from the second column onwards, where the Header Text would be the dates from GVDistinctDate, will display a Status of absent or present according to the studentID and the corresponding date. How do it get the dates from GVDistinctDate into the column Header Text of GVReport?
AND how do it display the Present or Absent status based on the studentID in column 1 GVReport and the dates on the Header Text? Below are the codes of how i got the distinct date into GVDistinctDate
[Code]....
The code below is for GVReport and the comments are where i tried to put in the dates into the column header text.
[Code]....
There is a problem here: GVReport.Columns(k).HeaderText = headerText Error:Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index
i have gridview in page and i want user see gridview2 to click on special data in column1 and user see gridview3 to click on special data in column2(gridview2 or gridview3 in everytime)
i use templateFiled for display gridview2 but when i want to display gridview3(with another templateField) , dont happen in gridview,
(I want to display nested gridview in GridView1 but GridView2 Or gridView3 by clicking on Column1 or column2)
Have the MultiView1 display only if Frieght values exceed 15.50. If check box is checked, retreive the row values of the Gridview1 and Gridview2 to perform a task.There will be two check boxes. One will be conditionally hidden. Each check box has a different function.
Example: Send an email notifying this entry has been flagged. I am using Visual Studio 2005 with ASP.NET 2 due to availability of resource. I have checked out numerous sites without finding the specific answer.
For example: [URL]
The following a simplified representative example of what I am trying to accoumplish. It uses the Northwind.mdb access database with just the Customers and Orders table.
the datatype in my database is Varchar, so that my gridview Sorting Function doesn't sort correct in sequence 1,2 3, 3 but 1,10,100, how can I sort in sequence 1,2,3,4 but no changing the datatype in database?
Why am I getting this error? I'm trying to do a calculation on my GridView2 and I'm using clientside javascript. I need to add the onkeyup attribute. How do I do this?
Code Behind:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load CType(GridView2.FindControl("TextBox13"), TextBox).Attributes.Add("onkeyup", "calculateSubTotal") End Sub
Here's my gridview when it comes it it's sorts on Age. Sorting is available for all columns/headers. How do I make the sort order to change on the ddsrpt sort to desc order when it's clicked?
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.
Just spent about 8 hours googling and looking through this forum for a solution on how to make sure that I can dynamically sort. Here is the situation.
I have 1 Gridview that displays 10 different scenarios based on what button is clicked.
I am also returning only top 10 records. I am doing all of the data binding pragmatically. So I have BoundFields, HyperLinkFields etc.
I also want to sort some records. When I change DataSource SQL statement the gridview somehow remembers what the last sort value was and it errors out saying that value "x" cannot be sorted because it does not exists.
Here I get an error that says that the data source does not support sorting? Doesnt it say gridview1.allowsorting = false;
I also tried gridview1.sort("", SortDirection.Ascending); This does nothin... except query my database one more time because i have a onSorting event that looks like this:
[Code]....
Here is an example of just one of those SLQ statements inside GetSQLQuery:
I have the gridview inside another gridview, i want to sort that both gridviews, I don't know how to achieve using asp.net 3.5 visual studio 2008 c# code behind. Following are my aspx page,
that aspx page contains gridview that contain one more gridview inside in it.Now i want to sort out both the grid i.e)claimgrid and Gdclmline1 i want code in c#.
I started a C# web project in Visual Web Developer. I dropped a grid view in with designer and connected to my remote SQL database with the designer dialog based wizard. All is well there. I have in my program also a textbox where a user enters a zip code and clicks a button 'search'. When the user clicks search I want to run the SQL command "select * from flat_list where zipcode='userszipcode'". In other words the userszipcode is dynamic and different every time. It is my understanding I should use a SQLDataSource object but I do not know how.