Search This Blog

Sunday, February 22, 2015

How to Custom Programming Webpart Create and In Webpart Create a gred view insert ,Edit and Delete Record In DataBase Using ADO.NET


1- Create A EmptySharepointProject.> Ok
2- put The Sharepoint Site (Where You Want To Debugging)
3- Select as 'Form Solution'
4- Add Item As Webpart
5- Now Use  Coding For This ...


using System;
using System.ComponentModel;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using System.Data.SqlClient;
namespace SharePointProject5.WebpartMadul
{
    [ToolboxItemAttribute(false)]
    public class WebpartMadul : WebPart
    {
        protected override void CreateChildControls()
        {
            using (var con = new SqlConnection(@"Datasource=.\sharepoint;Initial Catalog=NorthWind:Integrated Security=true"))
            {
                string query = "select  CategoryID,CategoryName from Categories";
                var cmd = new SqlCommand(query, con);
                con.Open();
                var list = new ListBox();//You Create Control  as  Gridview
                // or
                // var gvEV=new GridView();
                list.DataSource = cmd.ExecuteReader();
                list.DataTextField = "CategoryName";
                list.DataValueField = "CategoryID";
                list.DataBind();
                Controls.Add(list);
            }
         }
    }
}
6- F5 For debugging and Deploy
7- Now go to sharepoint Site
8-Go Site Action
9-Edit Page
10-Insert
11-Webpart Add> Custom > Add WebPart


No comments:

Post a Comment