Click here to Skip to main content
Rate this: bad
good
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 at 21-May-12 1:42am
   
What does that within the from date and to date means?
MaulikDusara at 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 at 21-May-12 2:06am
   
Krish, I din't used dtValue anywhere in my solution, are you talking about Technoses' solution?
m v krish at 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 at 21-May-12 2:05am
   
what is "dtvalue" in the solution given..
Technoses at 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
0 OriginalGriff 428
1 Maciej Los 249
2 BillWoodruff 199
3 /\jmot 180
4 Suraj Sahoo | Coding Passion 150
0 OriginalGriff 8,484
1 Sergey Alexandrovich Kryukov 7,407
2 DamithSL 5,639
3 Maciej Los 5,159
4 Manas Bhardwaj 4,986


Advertise | Privacy | Mobile
Web02 | 2.8.1411023.1 | Last Updated 21 May 2012
Copyright © CodeProject, 1999-2014
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