Click here to Skip to main content
15,892,005 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i want to generate gridview dynamically.

i have two options
1) user can select financial year from checkboxlist e.g april 2010 - march 2011
2) user can select date using calender control and date will be displayed in teaxtboxes.. e.g 1-4-2010 to 31-8-2010.

if user selects checkboxlist then in gridview collumn should be april, may,jun.... jan,feb,march

if user enters date in textbox then in gridview column should be april,may,jun,jul,aug.

i don't know how to do this and i stuck in my logic..
kindly help me out as soon as possible.
Posted
Comments
Herman<T>.Instance 27-Jan-12 3:37am    
please show your code kindly so we can see what you have tried to create

You can write a query based on the date and make a view in Sql and Bind this view to the Gridview.Hope this will help you.Happy Programming.
 
Share this answer
 
Comments
Member 8589824 27-Jan-12 3:43am    
yeah but every time dates will be changed so how can i write query which have different parameters every time??? can you elaborate your answer??
johannesnestler 27-Jan-12 6:01am    
What's the problem? Just make the parameters variables in your query. Maybe you are missing some basics? Asking questions wont help if you can't understand the answers... btw show some code...
Member 8589824 27-Jan-12 3:47am    
or can you tell me how view can be build?? i even don't know how to make a view based on date??
try this code
C#
	SqlConnection myConnection;
	string str_Account_Select = "SELECT * FROM AccountsTable where coumnname="+value+"";
	SqlCommand myCommand;
	DataSet myDataSet;
	myConnection = new SqlConnection(connectionString);
	myConnection.Open();
	myCommand = new SqlCommand(str_Account_Select, myConnection);
	SqlDataAdapter mySQLDataAdapter;
	myDataSet = new DataSet();
	mySQLDataAdapter = new SqlDataAdapter(myCommand);
	mySQLDataAdapter.Fill(myDataSet, "AccountsTable");
	GridView1.DataSource = myDataSet;
	GridView1.DataBind();
	
}
 
Share this answer
 
Comments
Member 8589824 27-Jan-12 3:58am    
this one 1 know but i am asking how can i differenciate months in query because in database only dates are stored and i n textbox user enters dates. e.g 1-4-2010 in one textbox and 31-8-2010 in other textbox. now i want to show column names april, may ,jun, july, august.. how can i do this??? or how can i apply query for differnet months??
uspatel 27-Jan-12 4:12am    
you can use it in query as DatePart to record according to month.as in eaxmple
select UPPER(name) as name,userid,Designation,Deptt from empbirth where day (dob)= datepart(day, getdate()) AND month(dob)= datepart(month, getdate())";
Member 8589824 30-Jan-12 1:07am    
thnk u... i m very close to solution.. but now i cam across with new problem.
i have quey like this..

select datepart(month,InvoiceMaster.InvoiceDate)as mnth ,sum(InvoiceMaster.value) from InvoiceMaster
group by datepart(month,InvoiceMaster.InvoiceDate),InvoiceMaster.InvoiceDate having InvoiceMaster.InvoiceDate between '2010-1-31' and '2010-12-31'

i want total amount values month wise...
when i am trying to execute this query it only sums up 1st month's values.. e.g. in my data it only sums up 9th month's values.. but then it doesn't sums up 10th,11th 12th month's value.. 9th month appears first so it sums up only 9th month's values..
Member 8589824 30-Jan-12 1:08am    
kindly help me for this one

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