473,395 Members | 1,977 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

GridView not being displayed: Lil silly mistake i guess....

Can somebody point out to the mistake i am making. I want ti display
a GridView upon selecting a date range in the combo boxes and clicking
the button "Go". Here is the code for it but it does not work and i
wrote a stored procedure to config. the data source.

public partial class ActivityLogs : System.Web.UI.Page
{
string[] daysinamonth;
public ActivityLogs()
{
daysinamonth=new string[12];
}
protected void Page_Load(object sender, EventArgs e)
{
// GridView1.Visible = false;
daysinamonth[0] = "January";
daysinamonth[1] = "February";
daysinamonth[2] = "March";
daysinamonth[3] = "April";
daysinamonth[4] = "May";
daysinamonth[5] = "June";
daysinamonth[6] = "July";
daysinamonth[7] = "August";
daysinamonth[8] = "September";
daysinamonth[9] = "October";
daysinamonth[10] = "November";
daysinamonth[11] = "December";
}
protected void GridView1_SelectedIndexChanged(object sender,
EventArgs e)
{
/*
string fromdate = dayList1.Text + "-" + monthList1.Text + "-"
+ yearList1.Text;
fromDate = fromdate + "T00:00:00.000";
string todate = dayList2.Text + "-" + monthList2.Text + "-" +
yearList2.Text;
todate = todate + "T00:00:00.000";

DateTime FromDate=DateTime.Parse(fromdate);
DateTime ToDate = DateTime.Parse(ToDate);

LogViewer.ViewActivityLog(Session["UserName"].ToString(),
FromDate, ToDate);
*/

}
protected void Button1_Click(object sender, EventArgs e)
{
string month1="";
string month2="";
for (int i=0;i<11;i++)
{
if (monthList1.SelectedItem.Text == daysinamonth[i])
{
int addition = i+1;
month1 = addition.ToString();
}
}
string fromdate = month1 + "/" + dayList1.Text + "/" +
yearList1.Text;
for (int i = 0; i < 11; i++)
{
if (monthList2.SelectedItem.Text == daysinamonth[i])
{
int addition = i+1;
month2 = addition.ToString();
}
}

// fromdate = fromdate + "T00:00:00.000";
string todate = month2 + "/" + dayList2.Text + "/" +
yearList2.Text;
//todate = todate + "T00:00:00.000";

DateTime FromDate = DateTime.Parse(fromdate);
DateTime ToDate = DateTime.Parse(todate);

Session["FromDate"] = FromDate;
Session["ToDate"] = ToDate;

//GridView1.Load();
GridView1.Visible = true;
}
}

Apr 12 '07 #1
1 1523
In ASP.NET you have to make a call to the DataBind method of the Gridview
after you have completed setting up its datasource and any other properties.
Peter

--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net


"weird0" wrote:
Can somebody point out to the mistake i am making. I want ti display
a GridView upon selecting a date range in the combo boxes and clicking
the button "Go". Here is the code for it but it does not work and i
wrote a stored procedure to config. the data source.

public partial class ActivityLogs : System.Web.UI.Page
{
string[] daysinamonth;
public ActivityLogs()
{
daysinamonth=new string[12];
}
protected void Page_Load(object sender, EventArgs e)
{
// GridView1.Visible = false;
daysinamonth[0] = "January";
daysinamonth[1] = "February";
daysinamonth[2] = "March";
daysinamonth[3] = "April";
daysinamonth[4] = "May";
daysinamonth[5] = "June";
daysinamonth[6] = "July";
daysinamonth[7] = "August";
daysinamonth[8] = "September";
daysinamonth[9] = "October";
daysinamonth[10] = "November";
daysinamonth[11] = "December";
}
protected void GridView1_SelectedIndexChanged(object sender,
EventArgs e)
{
/*
string fromdate = dayList1.Text + "-" + monthList1.Text + "-"
+ yearList1.Text;
fromDate = fromdate + "T00:00:00.000";
string todate = dayList2.Text + "-" + monthList2.Text + "-" +
yearList2.Text;
todate = todate + "T00:00:00.000";

DateTime FromDate=DateTime.Parse(fromdate);
DateTime ToDate = DateTime.Parse(ToDate);

LogViewer.ViewActivityLog(Session["UserName"].ToString(),
FromDate, ToDate);
*/

}
protected void Button1_Click(object sender, EventArgs e)
{
string month1="";
string month2="";
for (int i=0;i<11;i++)
{
if (monthList1.SelectedItem.Text == daysinamonth[i])
{
int addition = i+1;
month1 = addition.ToString();
}
}
string fromdate = month1 + "/" + dayList1.Text + "/" +
yearList1.Text;
for (int i = 0; i < 11; i++)
{
if (monthList2.SelectedItem.Text == daysinamonth[i])
{
int addition = i+1;
month2 = addition.ToString();
}
}

// fromdate = fromdate + "T00:00:00.000";
string todate = month2 + "/" + dayList2.Text + "/" +
yearList2.Text;
//todate = todate + "T00:00:00.000";

DateTime FromDate = DateTime.Parse(fromdate);
DateTime ToDate = DateTime.Parse(todate);

Session["FromDate"] = FromDate;
Session["ToDate"] = ToDate;

//GridView1.Load();
GridView1.Visible = true;
}
}

Apr 12 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: GregG | last post by:
Greetings, I have been working with the new GridView control, and while figuring out most of it's idiosyncrasies on my own, have stumbled upon a problem I cannot seem to resolve. We have...
1
by: joechipubik | last post by:
I have a GridView in a FormView that has as its datasource a DataTable that is stored in the session cache. When I first load the page the GridView is displayed correctly, but on subsequent loads...
1
by: mercercreek | last post by:
This one should be easy. Hope someone has a clue. Simple Scenario: Gridview with mulitple rows, each row with a checkbox. The user checks boxes of her choice. Clicks a button on the form (not in...
8
by: Greg Lyles | last post by:
Hi all, I'm trying to develop an ASP.NET 2.0 website and am running into some real problems with what I thought would be a relatively simple thing to do. In a nutshell, I'm stuck on trying to...
2
by: Richard Carpenter | last post by:
I have a four-page tabcontrol with a gridview on each page. I have the primary key column of each gridview set to hidden (visible = false), but it still shows up on all but the first page. Anyone...
1
by: sheenaa | last post by:
Hello Members, I m creating my application forms in ASP.Net 2005 C# using the backend SQL Server 2005. What i have used on forms :: ? On my first form i have used some...
3
by: =?Utf-8?B?c2xlbWVu?= | last post by:
Hi, My GridView is bound to a DataTable and the GridView properties are set as follows: AutoGenerateColumns="true" AutoGenerateEditButton="true" AutoGenerateDeleteButton="true" The Edit and...
1
by: Brian | last post by:
I currently have a GridView that displays information like: , Name, Address, City, State, Notes. Right now this information is displayed in columns but I would like it if each row in the table...
1
by: Joe Blauth | last post by:
Hi all, I was running into a problem with a gridview under ASP.net. What I am trying to do is binding the DataSource dynamically in a way that enables me to edit the rows in the Gridview. This...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.