dotnetspider.com
Login Login    Register      

TutorialsForumCareer DevelopmentResourcesReviewsJobsInterviewCommunitiesProjectsTraining

Subscribe to Subscribers
Talk to Webmaster
Tony John

Facebook
Google+
Twitter
LinkedIn
Online MembersManoj kumar sahu
Chandra
shivanarsireddy
Rakesh Chaubey
Ultimaterengan
nadh
jignesh
Ranipriya
Deepak Negi
More...
Join our online Google+ community for Bloggers, Content Writers and Webmasters




Forums » .NET » ASP.NET »

How to generate table in run time in another page


Posted Date: 19 Mar 2009      Posted By:: YuDi     Member Level: Gold    Member Rank: 115     Points: 1   Responses: 2



helle experts
I am generating a gridview at run time
I want that when user click the preview then the gridview data are shown in another page in table
their ar 5 column in gridview but
the no. of row are not dicided. It is auto generated by user

I want that when user preview this page
then these rows of gridview are display in tabular format in another page

so how can the table generated in run time and display the content of the previous page

Plz give suitable code
thanks



“Talent wins games, but teamwork and intelligence wins championships.”
umardaraj07@gmail.com




Responses

#357522    Author: Anil Kumar Pandey      Member Level: Platinum      Member Rank: 1     Date: 19/Mar/2009   Rating: 2 out of 52 out of 5     Points: 2

hi,

u can use the data table for that in which u can assign the row and columns according to ur need

after that u can bind that table with the grid.

please refer the following code for this task..


DataSet ds = new DataSet();
DataTable dt = ds.Tables.Add("Student");
dt.Columns.Add("Name", Type.GetType("System.String"));
dt.Columns.Add("Age", Type.GetType("System.String"));
dt.Columns.Add("Class", Type.GetType("System.String"));
dt.Columns.Add("Teacher", Type.GetType("System.String"));
dt.Columns.Add("Bio", Type.GetType("System.String"));
dt.Columns.Add("ID", Type.GetType("System.Int32"));
dt.Columns.Add("Grade", Type.GetType("System.String"));
dt.Columns.Add("TID", Type.GetType("System.Int32"));
dt.Columns.Add("Avtaar", Type.GetType("System.String"));


for (int i = 0; i < strArr.Length; i++)
{
if (Convert.ToString(strArr[i]) != "")
{
int lintSID = Convert.ToInt32(Convert.ToString(strArr[i]));
SqlDataReader drBio;
SqlDataReader drTeacher;
DataRow dr = dt.NewRow();

dr[0] = BobjStudent.GetStudentNamebyID(lintSID);
dr[1] = Convert.ToString(BobjStudent.getAge(lintSID));
dr[2] = BobjRelations.get_ClassName(lintSID);
if (Convert.ToString(dr[2]) != "")
{
drTeacher = BobjClass.get_TeachersByClassName(Convert.ToString(dr[2]));
if (drTeacher.HasRows)
{
while (drTeacher.Read())
{
dr[3] += Convert.ToString(drTeacher["Name"]) + "<br />";
dr[6] = Convert.ToString(drTeacher["Grade"]);
dr[7] = Convert.ToInt32(Convert.ToString(drTeacher["ID"]));
}
}
}
else
{
dr[3] = "";
}
drBio = BobjStaff.get_BioData(lintSID.ToString());
if (drBio.HasRows)
{
while (drBio.Read())
{
dr[4] = Convert.ToString(drBio["Biodata"]);
if (Convert.ToString(drBio["Avtaar"]) != "")
{
dr[8] = "Avtaar/" + Convert.ToString(drBio["Avtaar"]);
}
else
{
dr[8] = "Avtaar/Default_Avtaar.jpg";
}
}
}
else
{
dr[8] = "Avtaar/Default_Avtaar.jpg";
}
dr[5] = lintSID.ToString();
dt.Rows.Add(dr);
}
// Bind the data to the Repeater
rptParent.DataSource = ds;
rptParent.DataMember = "Student";
rptParent.DataBind();


Thanks & Regards
Anil Kumar Pandey
Microsoft MVP, DNS MVM



 
#357528    Author: Rizwan Ahmed      Member Level: Gold      Member Rank: 0     Date: 19/Mar/2009   Rating: 2 out of 52 out of 5     Points: 2

is it there a way here to avoid data table
so that we can generate grid directly
on run time.



 
Post Reply

 This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.



Next : Video demos
Previous : How i can display images
Return to Discussion Forum
Post New Message
Category:

Related Messages



Follow us on Twitter: https://twitter.com/dotnetspider

Active Members
TodayLast 7 Daysmore...

Awards & Gifts
Email subscription
  • .NET Jobs
  • .NET Articles
  • .NET Forums
  • Articles Rss Feeds
    Forum Rss Feeds


    About Us    Contact Us    Copyright    Privacy Policy    Terms Of Use    Revenue Sharing sites   Advertise   Talk to Tony John
    Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India
    2005 - 2012 All Rights Reserved.
    .NET and other trademarks mentioned in this site belong to Microsoft and other respective trademark owners.
    Articles, tutorials and all other content offered here is for educational purpose only.
    We are not associated with Microsoft or its partners.