|
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:  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:  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. |
|
|
|
|
 Follow us on Twitter: https://twitter.com/dotnetspider
|
|