Skip to content

Instantly share code, notes, and snippets.

@devendrasv
Created May 31, 2013 01:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save devendrasv/5682402 to your computer and use it in GitHub Desktop.
Save devendrasv/5682402 to your computer and use it in GitHub Desktop.
visual webpart cs
using System;
using System.ComponentModel;
using System.Web.UI.WebControls.WebParts;
using System.Data;
using Microsoft.SharePoint;
namespace First_VisualWebPart.VisualWebPart1
{
[ToolboxItemAttribute(false)]
public partial class VisualWebPart1 : WebPart
{
// Uncomment the following SecurityPermission attribute only when doing Performance Profiling using
// the Instrumentation method, and then remove the SecurityPermission attribute when the code is ready
// for production. Because the SecurityPermission attribute bypasses the security check for callers of
// your constructor, it's not recommended for production purposes.
// [System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Assert, UnmanagedCode = true)]
public VisualWebPart1()
{
}
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
InitializeControl();
}
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btngettickets_Click(object sender, EventArgs e)
{
DataTable dt = GetItemDetails();
ddltickets.DataSource = dt;
ddltickets.DataTextField = "Title";
ddltickets.DataValueField = "Title";
ddltickets.DataBind();
}
private DataTable GetItemDetails()
{
SPWeb spweb = SPContext.Current.Web;
SPList ticketsList = spweb.GetList("http://dvlabapp01.cloudapp.net/Lists/Ticket%20Details/AllItems.aspx");
return ticketsList.Items.GetDataTable();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment