Wednesday, August 30, 2017

// // Leave a Comment

How to show Gridview inside another Gridview


In this article I am going to explain how to Show Gridview inside a another Gridview

As the first step need to drag and drop a Gridview to design form and bind data as I have discussed in How to bind data with Gridview.
Next add template column as we discount in How to add Template column in Gridview.


We have to add a label to Item Template and bind data. Click on Label control and go to Edit data binding and bind the data field with field binding bound to. Then drag and drop another Gridview inside to Item Template and bind data.

Important thing is data source query. need to pass parameter to data source. We have to pass the value to data source from main Gridview template column.

Now you can see row wise data with related data with a another Gridview.



Read More

Monday, August 28, 2017

// // Leave a Comment

How to Add Template Column in Gridview


How to Add Template Column in Gridview

In this article I am going to explain, how to add template column in Gridview. As previous articles what I have explained as you have to drag and drop Gridview control to form. and bind SQL table with data source.


As showing in above image click on Gridview right hand side arrow, then pop menu will display, in the next step click on Add new Column.



and choose a field type from the dropdown list as TemplateField and input header in Header text box.
Press OK for apply the changes, new Template column will displayed in Grdview.

But still this Template column not bind with data field.

Bind data with Template column

Right click on the Gridview right hand side arrow, then menu will displayed and you have to select Edit Template.



Then you can see a sub menu with template column. click on the Template column.



Drag and drop Label to inside of Item Template and bind data



Clink on Label and Label Task menu will display, in this menu click on Edit binding, then above screen will display. Select the field name from Field binding and press OK.


Open with browser and you can see the bind data with template column.














Read More

Sunday, August 13, 2017

// // Leave a Comment

How to delete row in Gridview using C#



Watch Video

In this article I am going to explain how to delete row in Gridview using C# code.

Drag and drop GRiview controller to form and using data source bind data to Gridview.



Click on the Gridview and you can see arrow top right. When you click on arrow pop menu will display named as Gridview Tasks.

In that Gridview Task menu, you have to check the Enable Selection, and click on the Edit column. Next change the text on SelectedText as Delete. Then you can see the first column as Delete.



Next click on Gridview and go to properties and click Even icon, then you can see all events of Gridview.

From that event list go to SelectIndexChanges and double click. Then SelectIndexChanged event coding window will display and you can write the code as below

protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
    {
        GridViewRow row = GridView1.SelectedRow;
        txtBcode.Text = row.Cells[1].Text;
        txtBname.Text = row.Cells[2].Text;

        SqlConnection sqlConnection1 = new SqlConnection("Data Source=SERVER;Initial Catalog=SUPERMARKET;Integrated Security=True");

        SqlCommand cmd = new SqlCommand();
        cmd.CommandType = System.Data.CommandType.Text;
        cmd.CommandText = "DELETE Banks WHERE b_code =" + int.Parse(txtBcode.Text) + "";
        cmd.Connection = sqlConnection1;

        sqlConnection1.Open();
        cmd.ExecuteNonQuery();
        sqlConnection1.Close();

        GridView1.DataBind();

    }


Creating the SQL connection string as below

 SqlConnection sqlConnection1 = new SqlConnection("Data Source=SERVER;Initial Catalog=SUPERMARKET;Integrated Security=True");


After getting the SQL connection string and Open the SQL connection. As the next step execute the SQL Command for Deleting Record from SQL Table, and Bind the data source again to Gridview.

Actually Gridview row not deleteing from Gridview. Record deleting from SQL Database Table record and SQL Database Table again bind with Gridview using Data source.

Run the project and you can see data with Gridview with first column as Delete. when you click on Delete link button. Selected row will delete.

Watch Video
















Read More

Tuesday, August 8, 2017

// // Leave a Comment

How to delete row in Gridview using VB code



Watch Video

In this article I am going to explain how to delete row in Gridview using VB code.

Drag and drop GRiview controller to form and using data source bind data to Gridview.



Click on the Gridview and you can see arrow top right. When you click on arrow pop menu will display named as Gridview Tasks.

In that Gridview Task menu, you have to check the Enable Selection, and click on the Edit column. Next change the text on SelectedText as Delete. Then you can see the first column as Delete.



Next click on Gridview and go to properties and click Even icon, then you can see all events of Gridview.

From that event list go to SelectIndexChanges and double click. Then SelectIndexChanged event coding window will display and you can write the code as below


Protected Sub GridView1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridView1.SelectedIndexChanged
        Dim row As GridViewRow = GridView1.SelectedRow
        txtBCode.Text = row.Cells(1).Text
        txtBname.Text = row.Cells(2).Text

        Dim myConnection As SqlConnection = New SqlConnection(GetConnectionString)
        Dim myCommand As SqlCommand
        myConnection.Open()

        myCommand = New SqlCommand("DELETE Banks WHERE b_code =" & Val(txtBCode.Text), myConnection)
        myCommand.CommandType = CommandType.Text
        myCommand.ExecuteNonQuery()

        myConnection.Close()

        GridView1.DataBind()
    End Sub


Creating the SQL connection string as below

  Dim myConnection As SqlConnection = New SqlConnection(GetConnectionString)

GetConnectionString will com form Class1,vb Clase

Public Shared Function GetConnectionString() As String

        GetConnectionString = ConfigurationManager.ConnectionStrings("SUPERMARKETConnectionString").ConnectionString
        Return GetConnectionString
    End Function


SUPERMARKETConnectionString is getting from Web.config file

<connectionStrings>
    <add name="SUPERMARKETConnectionString" connectionString="Data Source=SERVER;Initial Catalog=SUPERMARKET;Integrated Security=True"
      providerName="System.Data.SqlClient" />
  </connectionStrings>

After getting the SQL connection string and Open the SQL connection. As the next step execute the SQL Command for Deleting Record from SQL Table, and Bind the data source again to Gridview.

Actually Gridview row not deleteing from Gridview. Record deleting from SQL Database Table record and SQL Database Table again bind with Gridview using Data source.

Run the project and you can see data with Gridview with first column as Delete. when you click on Delete link button. Selected row will delete.

Watch Video

















Read More

Monday, August 7, 2017

// // Leave a Comment

How to display mouseover effect in GridView rows C#


Data bind Gridview as previous projects. Watch Video

Click on the Gridview and open the property windows and click on Event icon.


Double click on RowCreated Event, coding window will open. and past the below code.

 protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
    {
        decimal RowValue = default(decimal);
        RowValue = decimal.Remainder(e.Row.RowIndex, 2);

        if (!(e.Row.RowIndex == -1))
        {
            e.Row.Attributes.Add("OnMouseOver", "this.style.backgroundColor = 'lightsteelblue';");

        }

        if (RowValue == 0 & !(e.Row.RowIndex == -1))
        {
            e.Row.Attributes.Add("OnMouseOut", "this.style.backgroundColor = '';");

        }
        else if (!(RowValue == 0) & !(e.Row.RowIndex == -1))
        {
            e.Row.Attributes.Add("OnMouseOut", "this.style.backgroundColor = '';");

        }
    }


Watch Video
























Read More
// // Leave a Comment

How to display mouseover effect in GridView rows VB


Data bind Gridview as previous projects. Watch Video

Click on the Gridview and open the property windows and click on Event icon.


Double click on RowCreated Event, coding window will open. and past the below code.

 Protected Sub GridView1_RowCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowCreated
     
        Dim RowValue As Decimal
        RowValue = Decimal.Remainder(e.Row.RowIndex, 2)

        If Not e.Row.RowIndex = -1 Then
            e.Row.Attributes.Add("OnMouseOver", "this.style.backgroundColor = 'lightsteelblue';")

        End If

        If RowValue = 0 And Not e.Row.RowIndex = -1 Then
            e.Row.Attributes.Add("OnMouseOut", "this.style.backgroundColor = '';")

        ElseIf Not RowValue = 0 And Not e.Row.RowIndex = -1 Then
            e.Row.Attributes.Add("OnMouseOut", "this.style.backgroundColor = '';")

        End If
    End Sub


Watch Video























Read More

Saturday, August 5, 2017

// // Leave a Comment

How to insert data to table using button click C#



In this article I am going to explain How to insert data to table using button click event with C#

First you have to create a new web project as we discussed earlier article. How to create new project with visual studio

Watch Video

I am going to user how to bind data with dropdownlist for this project also.

First we have to design screen layout, Text box and Button controller as the previous projects, you have to drag and drop controllers from toolbox to designing form.

Next you can change the ID from properties and double click on the Button controller
then button Click even coding screen will display.



You have to type the coding as displayed below.

using System.Data.SqlClient;

Coding for Button Click event

protected void btnSave_Click(object sender, EventArgs e)
    {
        SqlConnection sqlConnection1 = new SqlConnection("Data Source=SERVER;Initial Catalog=SUPERMARKET;Integrated Security=True");

        SqlCommand cmd = new System.Data.SqlClient.SqlCommand();
        cmd.CommandType = System.Data.CommandType.Text;
        cmd.CommandText = "INSERT Banks (b_name) VALUES ('" + txtBname.Text + "')";
        cmd.Connection = sqlConnection1;

        sqlConnection1.Open();
        cmd.ExecuteNonQuery();
        sqlConnection1.Close();

        GridView1.DataBind();
    }

Finally run the application and you can input name for text box and press Save button. Then bank name with save to SQL table.


For details Watch Video



Read More

Friday, August 4, 2017

// // Leave a Comment

Why Should You Move to Visual Studio 2010?


There are various motivations to move to Visual Studio 2010 Professional, and before we jump into the book parts to analyze them, we thought it is great to list a couple from a highlevel point of view (introduced with no need requesting):

Rich, new proofreader with worked in Windows Presentation Foundation (WPF) that you can profoundly redo to suit how you function.

New Quick Search, which finds pertinent outcomes just by rapidly writing the initial couple of letters of any strategy, class, or property.

Awesome help for creating and sending Microsoft Office 2010, SharePoint 2010, and Windows Azure applications.

Multi-core improvement bolster that enables you to parallelize your applications, and another particular debugger to enable you to track the errands and strings

Upgrades to the ASP.NET AJAX system, center JavaScript IntelliSense bolster, and the incorporation in Visual Studio 2010 of jQuery, the open-source library for DOM associations.

Multi-targeting/multi-framework bolster. Read Scott Guthrie's blog entry to get a comprehension of this incredible element

Support for creating WPF and Silverlight applications with upgraded dragand-drop support and information authoritative. This incorporates incredible new upgrades to the creators, empowering a higher loyalty in rendering your controls, which thusly empowers you to find bugs in rendering before they occur at run time (which is an awesome change from past variants of Visual Studio). New WPF and Silverlight apparatuses will help you to explore the visual tree and assess protests in your rich WPF and Silverlight applications.

Awesome help for Team Foundation Server (TFS) 2010 (and past renditions) utilizing Team Explorer. This empowers you to utilize the information and reports that are consequently gathered by Visual Studio 2010 and track and break down the soundness of your undertakings with the coordinated reports, and additionally keep your bugs and errands exceptional.

Coordinated help for test-driven advancement. Programmed test stub era and a rich unit test system are two decent test highlights that designers can exploit for making and executing unit tests. Visual Studio 2010 has extraordinary extensibility indicates that will empower you additionally utilize basic outsider or open-source unit test systems specifically inside Visual Studio 2010.

Be that as it may, the most vital explanation behind numerous designers and ventures to make the move is to have the capacity to focus on the genuine issues they're confronting as opposed to investing their energy translating code. You'll see that with Visual Studio 2010 you can take care of those issues speedier. Visual Studio 2010 gives you new, capable outline surfaces and effective apparatuses that assistance you compose less code, compose it quicker, and convey it with higher quality.

Read More

Thursday, August 3, 2017

// // Leave a Comment

How to Select record from Gridview using C#



I this article I am going to explain how to select record from Gridview using C# code.

As previous article, you have to create a new project.

How to create new project with Visual Studio

Watch Video

Also I have explained how to bind data with Gridview

How to bind data with Gridview

Watch Video

Design screen for Bank code and Bank name using Labels and Text Boxes. give them IDs as Bank Code as txtBcode and Bank Name as txtBname



Click on the Gridview and you can see arrow top right. When you click on arrow pop menu will display named as Gridview Tasks.

In that Gridview Task menu, you have to check the Enable Selection.

Then you can see new column added to Gridview and show Select for every row with Blue colour.

Next click on Gridview and go to properties and click Even icon, then you can see all events of Gridview.

From that event list go to SelectIndexChanges and double click. Then SelectIndexChanged event coding window will display and you can write the code as below


protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
    {
        GridViewRow row = GridView1.SelectedRow;
        txtBcode.Text = row.Cells[1].Text;
        txtBname.Text = row.Cells[2].Text;
    }


Run the project and you can see data with Gridview and first column as select. when you click on select link button. selected row bank code and bank name displayed on Bank code textbox and Bank name text box.

Watch Video
















Read More

Wednesday, August 2, 2017

// // Leave a Comment

How to create new project with visual studio 2010 C#


In this article I am going to show you how to create new project with visual studio 2010 C# 


01. Open Visual Studio 2010
02. Select file Menu
03. Select New
04. Select website

You can see a popup windows as below



From installed templates, you can select your Language as Visual C#. There are some templates according to your selected Language. As a beginner you have to select ASP.NET Web Site.
Select the Web Location for save your project. Select file system and brows your location.

It will load the selected template, Clicking solution explorer you can see the file structure of the project.

For testing purpose click the Run button. it will open with default browser.

This procedures are with below video. subscribe to this channel and get featured videos.




Related Links

Read More

Tuesday, August 1, 2017

// // Leave a Comment

How to Select record from Gridview using VB code



I this article I am going to explain how to select record from Gridview using VB code.

As previous article, you have to create a new project.

How to create new project with Visual Studio

Watch Video

Also I have explained how to bind data with Gridview

How to bind data with Gridview

Watch Video

Design screen for Bank code and Bank name using Labels and Text Boxes. give them IDs as Bank Code as txtBcode and Bank Name as txtBname



Click on the Gridview and you can see arrow top right. When you click on arrow pop menu will display named as Gridview Tasks.

In that Gridview Task menu, you have to check the Enable Selection.

Then you can see new column added to Gridview and show Select for every row with Blue colour.

Next click on Gridview and go to properties and click Even icon, then you can see all events of Gridview.

From that event list go to SelectIndexChanges and double click. Then SelectIndexChanged event coding window will display and you can write the code as below


Protected Sub GridView1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridView1.SelectedIndexChanged
        Dim row As GridViewRow = GridView1.SelectedRow
        txtBCode.Text = row.Cells(1).Text
        txtBname.Text = row.Cells(2).Text

    End Sub


Run the project and you can see data with Gridview and first column as select. when you click on select link button. selected row bank code and bank name displayed on Bank code textbox and Bank name text box.

Watch Video
















Read More