Click here to Skip to main content
12,067,278 members (55,461 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: ASP.NET Javascript HTML
From date:one text box
To date:one text box
taken .
after that i have taken one Submit Button. on clicking Submit Button I have to get Dynamic table within the Range of Dates i entered like a calender.Please Answer this.......
Posted 20-May-12 20:39pm
Edited 20-May-12 20:54pm
v2
Comments
Prasad_Kulkarni 21-May-12 1:42am
   
What does that within the from date and to date means?
MaulikDusara 21-May-12 2:12am
   
your question is not clear and also show code what you had done for this.
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

From the namespace System.Data DataTable DataColumn classes we can easily create table dynamically in C# and also in ASP.NET.

using System.Data;
 
// Create a DataTable instance
DataTable dTbl = new DataTable("myDynamicTable");
 
// Create a DataColumn instances

DataColumn dValue = new DataColumn();
DataColumn dMember = new DataColumn();
 
dValue.ColumnName = "Id";
dValue.DataType = Type.GetType("System.Int32");
 
dMember.ColumnName = "Name";
dMember.DataType = Type.GetType("System.String");
 
// Add these DataColumns into the DataTable

dTbl.Columns.Add(dValue);
dTbl.Columns.Add(dMember);

After you create table dynamically, you can add rows into it.
It is a good way to create DataRow from the table we create, with the function NewRow().

// Create a DataRow Instance from the table we create above, with NewRow();

DataRow myrow = dTbl.NewRow();
 
myrow["Id"] = 1;
myrow["Name"] = "Tux";
 
// Add the row into the table

dTbl.Rows.Add(myrow);

That's all for creating table dynamically in C# and also ASP.NET.
  Permalink  
Comments
Prasad_Kulkarni 21-May-12 2:06am
   
Krish, I din't used dtValue anywhere in my solution, are you talking about Technoses' solution?
m v krish 21-May-12 2:10am
   
It is about Technoses's solution.
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

From the namespace System.Data DataTable DataColumn classes we can easily create table dynamically in C# and also in ASP.NET .


DateTime dt1 = new DateTime(2012, 5, 1);//  From Date
DateTime dt2 = DateTime.Now;    // To Date

DataTable tbl = new DataTable("myTbl");
tbl.Columns.Add("dtValue", typeof(DateTime));
 
while (dt1 < dt2)
{
    tbl.Rows.Add(dt1.ToString("dd-MMM-yyyy"));
    dt1.AddDays(1);
}
  Permalink  
Comments
m v krish 21-May-12 2:05am
   
what is "dtvalue" in the solution given..
Technoses 21-May-12 12:12pm
   
this is column name in data table
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 3

This may help you,
Check this
  Permalink  

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web04 | 2.8.160208.1 | Last Updated 21 May 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100