473,406 Members | 2,208 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Displaying Records in Multiple Tables on each Page

Hi every one:

I just registered on forum today to get the help on a little but tricky problem to me.

Actually i am converting a php website into .NET C#. I just want to display each search record in each table.And also want paging on the search results. I am also attaching the link the php search results page. After clicking this http://legacy.southbeds.gov.uk/our-s...wapshop2.phtml just press search and you will see how the results are being displayed in PHP. I want same results in .net but not sure which control can do that.

Basically i am poping data from database by DataSet.
Any body can give me clue.

Thanks in advance
Jun 5 '07 #1
7 1837
kenobewan
4,871 Expert 4TB
Welcome to TSDN. Have you tried using a datatable, datagrid or gridview and enabled paging?
Jun 5 '07 #2
Welcome to TSDN. Have you tried using a datatable, datagrid or gridview and enabled paging?
Thanks for your prompt reply:

DataGrid/DataTable/GridView all looks to display the whole datasheet at once not in separate chunks as the PHP is doing in my example links.

If you can see the link i send you. i think Repeater control may do that. But still not sure. Still looking for the exact solution.

Regards
Mian
Jun 5 '07 #3
nateraaaa
663 Expert 512MB
You can do this with a datagrid/datatable/gridview the thing is that you need to create a datagrid/datatable/gridview for each result returned. I did something similar to this using a datagrid. I created a datagrid with two TemplateColumns and then used the Template columns to create the rows for the datagrid. Here is a portion of my html code.

Expand|Select|Wrap|Line Numbers
  1. <asp:datagrid id="dgResults" Runat="server" ShowFooter="False" ShowHeader="False" BorderWidth="1" BorderColor="Black" BorderStyle="Solid" Width="70%" AutoGenerateColumns="False" PageSize="10" AllowPaging="True">
  2. <Columns>
  3.   <asp:TemplateColumn>
  4.      <ItemTemplate>
  5.         <asp:Label ID="lblFirstColumn" Runat="server"></asp:Label>
  6.      </ItemTemplate>
  7.    </asp:TemplateColumn>
  8. <asp:TemplateColumn>
  9.      <ItemTemplate>
  10.         <asp:Label ID="lblSecondColumn" Runat="server"></asp:Label>
  11.      </ItemTemplate>
  12. </asp:TemplateColumn>
  13. </Columns>
  14. PagerStyle Visible="False" NextPageText="" PrevPageText=""></PagerStyle>
  15. </asp:datagrid>
For the set up of your datagrid you will want to create two TemplateColumns and then create a label control for each row that will be displayed in your datagrid. Looking at the website that your provided it looks like you will need 15 labels in each template column.

Now in the code behind I loop through each item returned to the datagrid.

//first create a global DataTable variable;
DataTable dtable = new DataTable();

//now create a method that you will call after you bind your data to the grid. I called this method BindTemplateColumns();

Expand|Select|Wrap|Line Numbers
  1. private void BindTemplateColumns()
  2. {
  3. dtable = ds.Tables["WhateverYouNamedYourDataSetTable"];
  4. for (int i = 0; i < dgResults.Items.Count; i++)
  5. {
  6.   DataRow row = dtable.Rows[i]; //this may affect your paging I had to use a Session value * a pageSize variable to correct an issue with paging.
  7. Label lbl1 = (Label)dgResults.Items[i].FindControl("lblFirstColumn")';
  8.   lbl1.Text = row["columnname"].ToString();
  9. Label lbl2 = (Label)dgResults.Items[i].FindControl("lblSecondColumn")';
  10.   lbl2.Text = row["columnname"].ToString();
  11. //repeat for every label that you create.
  12. }
  13. }
In your search button click event you will want to execute your search proc put the results in ds.Tables["WhateverYouNamedYourDataSetTable"] then assign your datasource of the datagrid to ds.Tables["WhateverYouNamedYourDataSetTable"]. Then call the DataBind method of the datagrid. Next call BindTemplateColumns().

Expand|Select|Wrap|Line Numbers
  1. dgResults.DataSource = ds.Tables["WhateverYouNamedYourDataSetTable"];
  2. dgResults.DataBind();    
  3. BindTemplateColumns();
I hope this helps.

Nathan
Jun 5 '07 #4
Thanks I really appreciate you guys on helping me but i still got issues as:

I got the theory in mind but still cant create Dynamically Array of DataGrid/DataTable.

I am trying to create an array of DataGrid and then displaying on the PlaceHolder. i.e:

DataGrid objDataGrid = new DataGrid[10];

But System giving me exception "Object reference not set to an instance of an object."

Please have a look on my question again and let me know how i can solve this issue.

Thanks again for giving me response...

Regards
Mian
Jun 6 '07 #5
Plater
7,872 Expert 4TB
Just do what the php script did.
Dynamicaly create a table object and populate it.
As for paging, again, just follow what the php script did, stick everything as params:
?page=2&area=&town=&bedrooms=&type=

And you can search from that like you normally would.
But when you see page=X you go:
"ok self, we display 5 results per page and since he wants page X i will skip X*5 entries and display entries (X*5)+1 up to ((X*5)+1)+4 (for a total of 5)"
then create your tables and add them to your page
Jun 6 '07 #6
Thanks for paging issue but the main issue is displaying data which i cant do with dynamic GridView/DataTable.

Thanks
Mian
Jun 7 '07 #7
Plater
7,872 Expert 4TB
Thanks for paging issue but the main issue is displaying data which i cant do with dynamic GridView/DataTable.

Thanks
Mian
I said use Table :-P
You can create an instance of a table in your code. Then you add columns/rows just like you would anything else. (The output will be an html table)
Jun 7 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

35
by: deko | last post by:
Do I get more scalability if I split my database? The way I calculate things now, I'll be lucky to get 100,000 records in my Access 2003 mdb. Here some math: Max mdb/mde size = 2000 x 1024 =...
1
by: NumberCruncher | last post by:
Hi All, I am struggling with setting up my first system of tables, forms,and reports, and could use your help! I am setting up a database to keep track of the production of a produced item. The...
11
by: shriil | last post by:
Hi I have this database that calculates and stores the incentive amount earned by employees of a particular department. Each record is entered by entering the Date, Shift (morn, eve, or night)...
0
chumlyumly
by: chumlyumly | last post by:
Hello scripters - OS: Mac OSX Language: PHP w/ MySQL database I've created an insert page where a user inputs his info, which then goes to four different tables in a MySQL database. The...
6
by: jasone | last post by:
Hi all! im developing a system where a user can select what flower goes into their bouquet, and ive become a little bit stuck... heres what ive done to date: currently ive got a page displaying...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.