Prasad Bolla's SharePoint Blog

Click Here to go through the Interesting posts within my Blog.

Click Here to go through the new posts in my blog.

Monday, November 28, 2011

Binding Events to calendar based on Calendar Date

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Prasad;
using System.Xml;
public partial class Default10 : System.Web.UI.Page
{
DataSet dset = new DataSet();
protected void Page_Load(object sender, EventArgs e)
{

}

protected void Calendar1_SelectionChanged(object sender, EventArgs e)
{


DateTime dtNow= Calendar1.SelectedDate;
string toDayFormat = dtNow.ToString("u");
string[] EventStartDate = toDayFormat.Split(new Char[] { ' ' });


Prasad.Lists listService = new Prasad.Lists();
listService.UseDefaultCredentials=true;
listService.Url = "http://vlnrm:100/_vti_bin/Lists.asmx";
string strListName = "Events";
System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();
System.Xml.XmlElement query = xmlDoc.CreateElement("Query");

System.Xml.XmlElement viewFields = xmlDoc.CreateElement("ViewFields");
System.Xml.XmlElement queryOptions = xmlDoc.CreateElement("QueryOptions");
viewFields.InnerXml = "";
//string strDate=Calendar1.s
//2010-08-10T00:00:00Z
//8/11/2010 12:00:00 AM
query.InnerXml = "" + EventStartDate[0] + "";
System.Xml.XmlNode nodeListItems = listService.GetListItems(strListName, null, query, viewFields, null, null, null);
//System.Xml.XmlNode nodeListItems = listService.GetListItems(listName, viewName, query, viewFields, rowLimit, queryOptions, null);
DataSet ds = getData(nodeListItems);
DataTable dt = ds.Tables["row"];
GridView1.DataSource = dt;
GridView1.DataBind();
System.Xml.XmlElement batchElement = xmlDoc.CreateElement("Batch");
batchElement.SetAttribute("OnError", "Continue");
batchElement.SetAttribute("ListVersion", "1");
}
public DataSet getData(XmlNode xmlnodeinput)
{
if (xmlnodeinput != null)
{
XmlTextReader xtr = new XmlTextReader(xmlnodeinput.OuterXml, XmlNodeType.Element, null);
//dataset = new DataSet();
dset.ReadXml(xtr);
}
return dset;
}
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Cells[2].Text = Convert.ToDateTime(e.Row.Cells[2].Text).ToShortDateString();
}
}
}

1 comment: