Click here to Skip to main content
15,901,426 members
Please Sign up or sign in to vote.
1.50/5 (2 votes)
See more:
i'm using two gridviews one is for courses and other one is for students..
so,
gridview1 shows courses .. and another students gridview must show the details of the student

C#
courses (course_id(101),title(asp.net),amount(5000))
student (student_id(01)),name(santosh),joining(22/12/2012)..)

this course parallely show the student in other gridview..
Posted
Updated 21-Jul-13 8:52am
v2
Comments
Thanks7872 22-Jul-13 0:17am    
Whats the question?
Dholakiya Ankit 22-Jul-13 0:36am    
what u need?
Ssntosh Chouhan 22-Jul-13 2:15am    
take two gridviews one is for courses another for student....
now you need to create a course,student table in sql express ..
bind it with grideview1,gridview2.. i hve done all this stuff but i cant able to get it
form id="form1" runat="server">
<div>


<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
<asp:GridView ID="GridView1" runat="server" EditIndex="0" EnableSortingAndPagingCallbacks="True">
<columns>

<asp:BoundField DataField="course_id" HeaderText="course_id" ReadOnly="true"/>

<asp:BoundField DataField="title" HeaderText="title" ReadOnly="true"/>

<asp:TemplateField HeaderText="amount">
<itemtemplate>
<%# Eval("amount") %>


<edititemtemplate>


<asp:GridView ID="GridView2" runat="server">
<columns>
<asp:TemplateField HeaderText="name">

<itemtemplate>
<%# Eval("student_id") %>
<%# Eval("name") %>
<%# Eval("joiningdate") %>
<%# Eval("course_id") %>
<%# Eval("feepaid") %>

























</div>
</form>


my question is when u run it on browser it must show like course id,title,amount---studentid ,name,joiningdate...
Ssntosh Chouhan 22-Jul-13 2:24am    
mr rohan,
if u have time can u plz come to TeamViewer nd sort out this pbm?

1 solution

Get your data from the database using the dataset and bind it to your gridview.

C#
Gridview1.DataSource=ds;
Gridview1.DataBind();


here is the list of examples for Gridview refer this

http://asp-net-example.blogspot.in/2008/10/gridview-example-how-to-use-gridview-in.html[^]
http://www.aspdotnet-suresh.com/2012/05/aspnet-gridview-examples-and-samples-in.html[^]


and to show the CourseId in second fridview means bind the course id in the stored procedure using joins because the student must contain the CourseId to mentin the student course name, right.
Refer this for joining the table.
http://www.w3schools.com/sql/sql_join.asp[^]

Hope it helps.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900