Hello everyone,
I have been trying to solve this problem from past two days. I am working for my project and stuck with this problem.
Please help me out, your help will be greatly appreciated.
Well, this is what I am trying to do:
1. I have following 3 tables: - a) Course
-
- CourseID, int, autoincrement
-
- CourseName, nvarchar(50)
-
- WeeksPerCourse, int
-
- ClassesPerWeek, int
-
-
b) Weeks
-
- WeekID, int, autoincrement
-
- WeekNumber, int
-
- CourseID
-
-
c) ClassTopics
-
- ClassTopicID, int, autoincrement
-
- ClassNumber, int
-
- TopicName, nvarchar(100)
-
- WeekID, int
Each course may have multiple weeks and each week may have multiple class topics.
And, now I want to display data from the above mentioned tables as follows in my "Index.aspx" page. - int weeks = "Select * from Weeks Where CourseID=1" //Say CourseID =1
-
<table>
-
//I want to repeat <tr> upto the number of weeks that the CourseID "1" has in Weeks table
-
<tr>
-
//I want to repeat <td> upto the number of classes for each week with CourseID "1"
-
<td> data </td> //I want to display "TopicName" of each class from "ClassTopics" table in between <td> cell
-
</tr>
-
</table>
Please kindly give me an idea on how to implement the above illustrated procedure.
Please let me know if I confused you.
I have tried with repeater control but unable to implement the above mentioned procedure.
Your help will be greatly appreciated. Thanks a million in advance.
3 1667
Are u using visual studio ??
Have you considered using a GridView to display the data?
Thanks for the replies.
I am using Visual Studio 2008 and C# to create/design ".aspx" pages.
After hours of tweaking, I have suceeded in implementing the above mentioned procedure using DataList, GridView and Repeater controls.
But, ran into another problem.
Your help/idea will be greatly appreciated.
Well, this is what I am trying to do:
1. I have following 3 tables: - a) Weeks
-
- WeekID, int, autoincrement
-
- WeekNumber, int
-
- CourseID
-
-
b) CourseMaterials
-
- CMFile_ID, int, autoincrement
-
- CMFile_UID, uniqueidentifier
-
- CMFile_Name1, nvarchar(Max)
-
- CMFile_Name2, nvarchar(50)
-
- CMFile_Content, image
-
- CMContent_Type, nvarchar(50)
-
- WeekID, int
-
-
c) CMLinks
-
- CMLink_ID, int, autoincrement
-
- CMLink_Name, nvarchar(50)
-
- CMLink_URL, nvarchar(Max)
-
- WeekID, int
2. "Index.aspx" page - <asp:DataList ID="CourseDataList" runat="server">
-
<ItemTemplate>
-
<tr>
-
<td><%#DataBinder.Eval(Container.DataItem, "WeekNumber")%></td>
-
<td>
-
<asp:Repeater ID="CMRepeater" runat="server" DataSource='<%#DataBinder.Eval(Container, "DataItem.WeekCMs")%>'>
-
<ItemTemplate>
-
<li><%#DataBinder.Eval(Container.DataItem, "CMFile_Name2")%></li>
-
</ItemTemplate>
-
</asp:Repeater>
-
</td>
-
</tr>
-
</ItemTemplate>
-
</asp:DataList>
3. "Index.aspx.cs" Page - private int courseID=1;
-
protected void Page_Load(object sender, EventArgs e)
-
{
-
bindData();
-
}
-
private void bindData()
-
{
-
SqlConnection con = new SqlConnection();
-
con.ConnectionString = "" // Defined my connection string here
-
con.Open();
-
-
SqlCommand sql1 = new SqlCommand("Select * From Weeks Where CourseID='" + courseID + "'", con);
-
sql1.CommandType = CommandType.Text;
-
SqlDataAdapter adapter1 = new SqlDataAdapter(sql1);
-
adapter1.TableMappings.Add("Table", "Weeks");
-
DataSet ds = new DataSet("Weeks");
-
adapter1.Fill(ds);
-
-
SqlCommand sql2 = new SqlCommand("Select * From CourseMaterials", con);
-
sql2.CommandType = CommandType.Text;
-
SqlDataAdapter adapter2 = new SqlDataAdapter(sql2);
-
adapter2.TableMappings.Add("Table", "CourseMaterials");
-
adapter2.Fill(ds);
-
-
DataColumn parent = ds.Tables["Weeks"].Columns["WeekID"];
-
DataColumn child = ds.Tables["CourseMaterials"].Columns["WeekID"];
-
ds.Relations.Add("WeekCMs", parent, child);
-
-
CourseDataList.DataSource = ds;
-
CourseDataList.DataBind();
-
-
con.Close();
-
}
The above functionality is working perfectly fine. I am able to display each week "WeekNumber" and course materials in a course timeline.
But, I also want to display each week course links from the above "CMLinks" table by including the following line in the above repeater control at line #9 (in "index.aspx" page) -
<li><%#DataBinder.Eval(Container.DataItem, "CMLink_Name")%></li>
Any thoughts/ideas on how to display course links along with course materials for each week in the course timeline?
Please help me out. Thanks a million in advance.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: peter |
last post by:
Hi,
I have 2 questions:
1) I have read the articles on how to embedd and image in a resource
file. I have also read the articles on how to open it from the
resource file and put it in a...
|
by: Murphy |
last post by:
Our website contains subdirectories for each subsidiary company, each
company has it's own look and feel to the pages in their subdirectory
although they are all part of the main website.
The...
|
by: BoltonWolf |
last post by:
Hi,
I was wondering if someone could give me a bit of advice on achiving
something.
I have a page with a panel on it. Is it possible to then load content
into the panel from a second aspx...
|
by: digitalego |
last post by:
Sorry if the title is a little confusing... Here is the problem.
I am working with a "default.aspx" page that uses a user control I
made:
------------------------------
| default.aspx ...
|
by: Pierre |
last post by:
Hello,
In an aspx page (mypage.aspx) from a web projet,
I would like to get the value of a variable of the projet that is declared
as public in a module.
The variable can be called from...
|
by: mazdotnet |
last post by:
Hi,
I have the following code in the code-behind file
public string section;
section = Request.ToString()
and I like to display it in my .aspx page (included .ascx) but it's not
working.
|
by: =?Utf-8?B?TWF0dE0=?= |
last post by:
Is there a way to display/render an ASP page inside of an ASPX page with ASP
..Net 2.0? I'm not trying to back into frames but I have an application that
will allow me to customize complex rendered...
|
by: toddwerts |
last post by:
I have an aspx page with some form controls in it. They all work fine except for one thing, the control (list) that is populated based on the selected item in the first control (dropdownlist1) is...
|
by: =?Utf-8?B?QWxleCBNYWdoZW4=?= |
last post by:
I have a MasterPage. The MasterPage actually contains the <formtag which is
used throughout the site.
On just certain pages that use that MasterPage, I need the "enctype" for the
<formtag to be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
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
|
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...
|
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...
| |