how to bind the two different queries in a single repeater? - asp.net

I need to bind to data into a repeater based up on two different Queries. The Fields are different for the two queries. How to bind the both queries into single repeater?

I do not understand your requirements. If you want to bind a nested repeater , then you can do it by binding the nested repeater in Item_Databound event to the query. If you want to bind the few controls in the same repeater to one query and few to another , then rethink what you are doing , may be you can do it with the one query.
It will be good if you explain your question in more details.
Thanks.

Related

Bind to a page in ASP.NET

I am confused about something really simple in ASP.NET. I have seen many times a pattern where there is a three column table, with label, control and validator in each column, which I can put together pretty straightforwardly. However, what I don't understand is how to handle binding here. If I have a table with Customer record and FirstName, LastName and PhoneNum, I want a page that takes customerId in the query string, and binds that record to the page so that I can use Bind() as the text box values.
However, there is no DataSource property on the page to bind the record to. I know I am missing something obvious, but I can't figure it out.
Any help would be appreciated.
You need to put your controls (labels, textboxes, validators) inside a control that accepts data binding (ie. FormView, GridView, Repeater, etc.etc.) and then bind your data to that control.
One way to do this is to use a DataSource Control such as a SqlDataSource and use it in conjunction with a Data Control that will bind to the previous datasource control like a DetailsView. Then you configure your DataSource control to only bring in data for the particular CustomerId; the SqlDataSource allows you to use a QueryStringParameter as part of the select statement to the database.
Each of the above controls have wizards that will allow you to easily configure them.

Linqdatasource group by problem with multiple table

I'm using linqdatasource for displaying data in listview (nested because of grouping) control. I want to display data from more than one table.
I'm using VWDExpress.
I have implemented this solution using nested datalist controls.

How to add a FooterRow to a Gridview which has no value initially

I have a Gridview in which no rows populated initially. means i am not setting any datasource to gridview.I have to populate gridview by adding footerrow.I have given visibility of footerrow as true.So one error is coming as 'Object not set to an instance of an object'.what may be the reason for this? Can anybody help?
Actually i need to add data into the Gridview through the FooterRow.After inserting a few records,i need to insert this data into the database.So, i want this Gridview only to insert data into the database.For a particular "FileID", i have many records,thats why i am using Gridview.Is there any other method for this?
See this question: How to insert a Row in GridView.
The object reference error is probably because you have set no datasource for the GridView. In such cases, the Gridview will not render.
Edit:
I have already linked to another question which provides a very useful link to accomplish the type of functionality you desire. Since you appear not to have found it, here is the relevant link - How to easily insert row in GridView with SqlDataSource?
The article shows how you can use the EmptyDataTemplate of the GridView to enable record insertion using a GridView. Note that you will have to modify the logic a little to insert a group of records in one go, rather than one at a time.
If you have a problem with this solution, please clarify via comments.

Custom Paging on GridView Populated by Button Press

I've got a Gridview that's populated by a Search button and I'm not sure how to go about doing custom paging for it. I run the search query using sp_executeSQL right now and it returns the entire resultset.
I'd like to know what steps I should take to set up custom paging and sorting on the GridView and the most efficient way to modify a procedure that uses Sp_ExecuteSQL to generate a result that's a single page. I've seen methods that use a temporary table, etc.
Once I have the proc written, how do I set up the events in the page?
asp:gridview comes with a paging setup if you didn't know that has sorting and paging with a certain number of fields techniques that are found http://www.dotnetspider.com/resources/1249-Grid-View-Paging-Sorting.aspx
But if you want to come up with your own paging technique which sounds like paging or sorting in the Database then this is different from paging in memory, which is what the asp:gridview webcontrol does. So if you want to page and sort from DB then you should create a stored procedure that does this and when it comes to your search button call that procedure which will take in your specific paramters(page number, how many entries per page,etc..)
This site https://web.archive.org/web/20210510021915/http://aspnet.4guysfromrolla.com/articles/031506-1.aspx goes much in detail on how better paging and sorting is if down from the DB

Nesting a GridView within Repeater

I have a scenario wherein, for example, I need to repeat a list of US states and display a table of cities and city populations after the name of each state. The design requirement dictates that every outer repetition must be the name of a state followed by a table of cities, and that requirement cannot be changed at this time. Are there disadvantages to nesting a GridView within a Repeater and then binding each repeated GridView during the Repeater's ItemDataBound event? What are some alternative solutions?
If it were me, I'd reverse the question and ask why I should use a GridView, If you need a bunch of built-in features like paging and sorting, then the GridView might be a good fit. If you just want tabular data, I'd reconsider. Why? Because with GridView you're getting a whole bunch of stuff you won't use, your ViewState will be potentially huge, and your page performance will be slower.
I'm not a bigot when it comes to GridView, but I only use them when there is a damn good reason.
In your above scenario, you'd be better off doing a master-detail style GridView, which will save you the overhead of all those GridView objects that get created.
There are various implementation of it (using a drop down for the master, using a modal popup for the detail, etc.), but the main point is that there are implementations available.
At the very least, hopefully you can turn off ViewState on the GridViews.
The best solution I was able to come up with was to nest the GridView in the Repeater. Then I bound each repeated GridView during the Repeater's ItemDataBound event. I turned off their ViewStates, of course, as they weren't required.

Resources