Tuesday, 29 October 2013

Stored Procedure (with input parameter) in ADO.Net

For Asp.net Training Fill the Enquiry Form
Stored Procedure
(with input parameter) in ADO.Net

Stored procedure is the precompiled form of queries which executed to perform some task. We can also call stored procedure using Ado.net.

 In this task I have created insertion procedure for the following table insertion:-



Figure 1

In this table id is an identity column.

Step 1:-

Create stored procedure for the insertion. I have created the stored procedure using input parameters:-

create proc data_ins( @name varchar(100),@age int)
as
insert into emp values( @name, @age)

Monday, 22 April 2013

Themes in Asp.net


Written By:- Isha Malhotra(malhotra.isha3388@gmail.com)
If you find this article useful then leave your comment

Themes in Asp.net

Sometimes we need to change the layout of application for different-different user. For example if a single application is used by different-different client and every client has his own color schema, logo, font etc. requirements then we use themes
A theme is a collection of skin files, css, graphics, images etc.

Add Theme

To add theme we have to first create the theme folder using name App_Themes.



Figure 1

Saturday, 13 April 2013

Store Image in folder from asp.net and show in the Gridview


Written By:- Isha Malhotra(malhotra.isha3388@gmail.com)
If you find this article useful then leave your comment


Store Image in Folder from asp.net and show in The Gridview

In this article I am Representing how to store images in folder and show in the gridview.

For Example

Check the following form Where I am taking the detail of product with image;-




Figure 1

Friday, 12 April 2013

Gridview in Asp.net- Part 1

Written By:- Isha Malhotra(malhotra.isha3388@gmail.com)
If you find this article useful then leave your comment
Gridview - Part 1

Gridview is used to show the data on your Screen from database. In this article I will explain how to work with gridview. Following are some functionality which we can perform on gridview.

Show Data in Gridview

To show the data on gridview first add gridview on your form and select the data from database by using the following connectivity:-
Default.aspx.cs:-
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            //Create connection. kindly change the conn_string according to your system

            string conn_string = "Data Source=Isha-PC;Initial Catalog=TechAltum;Integrated Security=True";
            SqlConnection con = new SqlConnection(conn_string);

            //create command object
            SqlCommand cmd = new SqlCommand();

            //pass connection and query to your command object
            cmd.Connection = con;
            cmd.CommandText = "Select * from Prod_rep";

            //create adaptor to fill data from database
            SqlDataAdapter da = new SqlDataAdapter(cmd);

            //create datatable which holds the data
            DataTable dt = new DataTable();
            da.Fill(dt);

            //bind your data to gridview
            GridView1.DataSource = dt;
            GridView1.DataBind();
        }
    }
}

Sunday, 31 March 2013

create single event for multiple Button or LinkButton


For Asp.net Training  Click Here

Written By:-Isha Malhotra
Email:-malhotra.isha3388@gmail.com


How to create single event for multiple Button or LinkButton

In my last article I discussed how we create event for control which we generate at runtime. In this article I am discussing how to create a single event for multiple controls and how we access all control through single even.

Just remember the example for searching where a list is showing with alphabet and on which alphabet we click the list generated according to it.

I am taking the same example here.



Figure 1

Friday, 29 March 2013

Add Click Event in Button at Runtime


For Asp.net Training  Click Here

Written By:-Isha Malhotra
Email:-malhotra.isha3388@gmail.com


Add Click Event in Button At Runtime

In my last article I discussed how to create control at runtime. Now I am discussing that if we want to make any event on any control then how we generate. To understand the concept of event you must have the knowledge of Delegate

For Example:-

In my Last Artical I create simple program of two number sum where I created control at run time. I am continuing with same example in which now I am creating event for button click and performing sum operation on that controls which we generated at runtime.

In this article I also explain how to access the runtime generated control.

To add event in the button I have to use the delegate EventHandler and add it in the click event and pass the reference of method to the EventHandler which will fire when we click on the button.

Create following method (you can say it event for button click)

protected void btn_Click(object sender, EventArgs e)
    {
   

   
    }

Now we have to pass the reference of this method to that button which we create at runtime. We have to add this reference to the event handler.

  Button btn_Sub = new Button();
        btn_Sub.ID = "bSum";
        btn_Sub.Text = "Sum";
        btn_Sub.Click += new EventHandler(btn_Click);

Thursday, 28 March 2013

Create Controls at Runtime in Asp.net


For Asp.net Training  Click Here

Written By:-Isha Malhotra
Email:-malhotra.isha3388@gmail.com

Create Controls at Runtime in Asp.net

In our working sometimes we need to create control at run time instead of compile time. In this article I am discussing how to create control at runtime.

Remember your first program in asp.net where you create sum of two numbers. At that time you create control at the compile time and show output on button click.

Same example I am taking here but I am creating control at runtime.

For Example:-

Take one panel at your design page so that you can add controls at runtime. Now check the following code:-

Default.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <asp:Panel ID="Panel1" runat="server">
    </asp:Panel>
    </form>
</body>
</html>

Default.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        //declare the object of table, Table row and Table Cell.
        Table TechAltum_Table = new Table();
        TableRow TechAltum_Row;
        TableCell TechAltum_Cell;

        //now create your first row
        TechAltum_Row = new TableRow();

        //now create your first cell

        TechAltum_Cell = new TableCell();

        //Now add message in the cell
        TechAltum_Cell.Text = "Enter First Number";

        //now add this cell in the row
        TechAltum_Row.Cells.Add(TechAltum_Cell);

        //now create second cell where we add one textbox
        TechAltum_Cell = new TableCell();