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

W

weird0

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)
{
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)
{
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;
}
}
 
G

Guest

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top