Shalvin Interests

Monday, January 27, 2014

ASP .Net GridView Editing


<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" OnRowCancelingEdit="GridView1_RowCancelingEdit" OnRowDeleting="GridView1_RowDeleting" OnRowEditing="GridView1_RowEditing" OnRowUpdating="GridView1_RowUpdating">
    <Columns>
         <asp:BoundField DataField="Contactid" HeaderText="CId" ReadOnly="True" />
         <asp:BoundField DataField="contactname" HeaderText="name" />
         <asp:BoundField DataField="Phone" HeaderText="Phone" />
         <asp:CommandField ShowEditButton="True" />
         <asp:CommandField ShowDeleteButton="True" />
    </Columns>
</asp:GridView>



using System.Configuration;
using System.Data;

public partial class _Default : System.Web.UI.Page
{
    SqlConnection cnn = null;

    protected void Page_Load(object sender, EventArgs e)
    
    {
        if (!IsPostBack)
        {
            GetData();
        }
    }

    private void GetData()
    {
        using (cnn = new SqlConnection(ConfigurationManager.AppSettings.Get("Cnn")))
        {

            SqlDataAdapter da = new SqlDataAdapter("select ContactId, ContactName, Phone from Contacts", cnn);
            DataSet ds = new DataSet();
            da.Fill(ds, "Co");
            GridView1.DataSource = ds.Tables["Co"];
            DataBind();
        }
    } 
    
    protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
    {
        GridView1.EditIndex = e.NewEditIndex;
        GetData();

    }
    protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        using (cnn = new SqlConnection(ConfigurationManager.AppSettings.Get("Cnn")))
        {
            cnn.Open();
            string id = GridView1.Rows[e.RowIndex].Cells[0].Text;
            string name = ((TextBox)GridView1.Rows[e.RowIndex].Cells[1].Controls[0]).Text;
            string phone = ((TextBox)GridView1.Rows[e.RowIndex].Cells[2].Controls[0]).Text;
            string strSql = "update Contacts set ContactName = '" + name + "', phone = '" +
                phone + "' where ContactId = " + id;

            SqlCommand cmd = new SqlCommand(strSql, cnn);
            cmd.ExecuteNonQuery();
            GridView1.EditIndex = -1;
            GetData();
        }

    }
    protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
    {
        GridView1.EditIndex = -1;
        GetData();
    }
}

Saturday, January 25, 2014

C# Method Overloading


 public void Display()
  {
    Response.Write("Hello " + "<br/>");
  }
  public void Display(string Name)
  {
    Response.Write("Hello " + Name + "<br/>");
  }
  public void Display(string Name, string Location)
  {
    Response.Write("Hello " + Name + " located at " + Location + "<br/>");
  }

  protected void Button1_Click(object sender, EventArgs e)
  {
    Display();
  }
  protected void Button2_Click(object sender, EventArgs e)
  {
    Display("Aiju");
  }
  protected void Button3_Click(object sender, EventArgs e)
  {
    Display("Sarath", "Trissur");
  }

C# Abstract Class


public abstract class CalcAb
{
  public abstract int Add(int i, int j);

  public int Subtract(int i, int j)
  {
    return i - j;
  }
}

public class Calc : CalcAb
{
  public override int Add(int i, int j)
  {
    return i + j;
  }
}

protected void Page_Load(object sender, EventArgs e)
{
  Calc c = new Calc();
  Response.Write(c.Add(78, 56));
  Response.Write("<br/>");
  Response.Write(c.Subtract(78, 67));
}

Monday, March 4, 2013

Kodiswaran March 3rd Question and Answers


1. Finger in which  ink in applied after election - left index finger.

2. Musical  instrument associated with Pandit Ravishankar -Sithar.

3. Number of chessmen in a standard chessboard -32.

4. Average body temperature of human being - 37

5. MP from Alappey who became Civil Aviation Minister on Oct 29 2012 - K C

Venugopal

6. ICC Cricket 2015 hosts - Australia and New Zealand

7. Pakshipathalam in Bhahmagiri hills is located at - Vayanad
http://en.wikipedia.org/wiki/Brahmagiri_(hill)

8.   Kerala Sahithya Academy Award recepient for the work 'Or Pidi Nellikka'-

Edasseri

9. Number of Rasas in Navarasas - 9

10. According to Mahabharath Keechakan was killed by - Bhiman







Wednesday, February 27, 2013

SharePoint 2010 Enterprise Databases

Following are the databases that gets created with SharePoint 2010 Enterprise installation:


Application_Registry_Service
Bdc_Service_DB
Managed_Metada_Service
PerformancePointServiceApplication
Search_Service_Application_CrawlStoreDB
Search_Service_Application_DB
Search_Service_Application_PropertyStoreDB
Secure_Store_Service_DB
SharePoint_AdminContent
SharePoint_Config
StateService
UserProfileServiceApplication_ProfileDB
UserProfileServiceApplication_SocialDB
UserProfileServiceApplication_SyncDB
WebAnalyticsServiceApplication_ReportingDB
WebAnalyticsServiceApplication_StagingDB
WordAutomationService
WSS_Content
WSS_Logging
WSS_Search

Monday, December 10, 2012

Drummer jokes


1. A guitarist asked a drummer why he prefers drum over guitar. The drummer answered atleast with drums you can loose cholesterol.

2. A guitarist wanted to torture the drummer, so he hid one of the drummer's sticks. After looking around, the drummer fell to his knees, raised his eyes to heaven, held up his remaining stick, and said, "Thank you Lord, for making me a conductor".


3. Two girls are walking down the road  when they hear, "Ssh! Down here". They looked down and see a frog, who says, "If you kiss me I'll turn into a famous drummer and make you rich and famous". One of the  girls reached down, grabs the frog, and stuffs it in her purse. The other girl says,  "Aren't you going to kiss him"? The first girl says, "No way! A talking frog is worth more than a famous drummer any day".


4. Why is a drum machine better than a drummer?
A. Because it keeps a steady beat and won't try to steal your girlfriend.


5. What's the difference between a drummer and government bonds?
Government bonds eventually mature and earn money.

6.What's the definition of a gentleman?
A. Someone who knows how to play the drums - but doesn't.