Saturday, July 29, 2017

// // 1 comment

How to bind data with Gridview using VB code



In this article I am going to explain, how to bind data with Gridview using code. In previous article
How to bind data with Gridview , I have explained data binding with data source.

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

Drag and drop Button control and Grid view control in to Design form.



with double clicking on Button control you can go to button click event coding window.

Imports System.Data
Imports System.Data.SqlClient
Imports Class1
Partial Class _Default
    Inherits System.Web.UI.Page
    Protected Sub btnView_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnView.Click
        Dim ds As New SqlDataSource
        Dim QString As String
        QString = "SELECT [b_code], [b_name] FROM [Banks]"
        ds.ConnectionString = GetConnectionString()
        ds.SelectCommand = QString
        GridView1.DataSource = ds
        GridView1.DataBind()
    End Sub
End Class

I have explained how to get connection with database Table in previous article and also you can what the Video.

Watch Video






























Read More

Wednesday, July 26, 2017

// // Leave a Comment

How to insert data to table using button click VB



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

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.


Import  System.Data.SqlClient

Coding for Button Click event

Imports System.Data
Imports System.Data.SqlClient
Imports Class1
Partial Class _Default
    Inherits System.Web.UI.Page

    Protected Sub brnSave_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles brnSave.Click
        Dim myConnection As SqlConnection = New SqlConnection(GetConnectionString)
        Dim myCommand As SqlCommand
        myConnection.Open()

        myCommand = New SqlCommand("INSERT INTO Banks ( b_name) VALUES ('" & txtBankName.Text.Trim & "')", myConnection)
        myCommand.CommandType = CommandType.Text
        myCommand.ExecuteNonQuery()
        myConnection.Close()
        DropDownList1.DataBind()
    End Sub

End Class

Make the connection String using Class1.vb

Imports Microsoft.VisualBasic
Imports System.Configuration
Public Class Class1
    Public Shared Function GetConnectionString() As String

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

End Class

Connection String getting form Web.config

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



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



Related articles









Read More

Tuesday, July 25, 2017

// // Leave a Comment

How to bind data with dropdownlist VB

In this article I am going to explain how to bind data with dropdownlist

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

Watch Video

After create the project, you have to drag and drop dropdownlist controller to form designer view.

Then click on dropdownlist controller and create the data source.




as the above picture, select SQL database and input name for data source and press OK button.




Then select how would you like to retrieve data from database. you have to select the data connection, if not available data connection, you have to create using New Connection button. After creating newly or selected with available, press next button.




Next we have to configure the select statement. There are 2 option 

01. Specify custom SQL or Stored procedure
02. Specify column from table or view

01. Specify custom SQL or Stored procedure

Select  Specify custom SQL or Stored procedure and press next button.




In this screen you can select to options with SQL statement or Stored Procedure.

I this article I am going to explain with SQL statement . Press Query Builder for create the SQL statement.

Select the Table from Add Table and press Add button, then table will display in query builder windows.



From this query builder windows you can create your Select statement by selecting fields of the table.

and pressing Execute query button you can see the result of SQL select statement.

Pressing OK button Query builder screen close and return to previous screen, in this screen you can see the created SQL statement inside the SQL statement text box.

Pressing next you can go to next screen (Test Query) and here also again you can Test the SQL statement. And pressing OK button return to Choose data source screen.

After this process you can see the data source name with Selected data source.




There are two options

01. Select a data field to display in the DropDownlist

02. 
Select a data field for the value of the DropDownlist

After selecting field for these two option and press OK button. Then Data source is bind with Dropdownlist.

Final when you run the application you can see the data listed with dropdownlist.




This article is with video  Watch Video.


Related articles














Read More

Friday, July 21, 2017

// // Leave a Comment

How to filter Gridview with Dropdownlist VB

In this article I am going to explain How to filter Gridview with Dropdownlist in Asp.net. Watch Video


01. Open a web project.
02. Drag and drop Dropdownlist to form
03. Drag and drop Gridview to form


Open a new project as I explained in How to open new project. Watch Video


After create the project, you can clear the form unwanted things and inset a table with 2 row. one row for Dropdownlist and other row for Gridview.

First drag and drop the dropdownlist controller to to form and link with data source.



As the next step drag and drop the Gridview controller to form and link with data source. In this case you have to do special thing.




care fully watch this 2 steps. this is the place linking dropdownlist and gridview. also remember to select Enable post back on droupdown controller.


For better understanding please watch the video Click here


Read More
// // Leave a Comment

How to bind data with GridView VB

In this articleI am going to explain how to bind data with Griview. Watch Video

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

After create the new project, open a aspx form with design mode. select the Toolbox,


Go to data category and drag the Gridview control to form. Selecting the right side top corner arrow. you can see a popup window with selecting place for Data source



Select your Data Source Type - SQL Database and you can have a name for it.
Next step is to Select your connection type. This step is doing onetime for project. (Creating New  connection). from the next time when you are creating Data Source, you have to select the created Connection.

Click on New connection button, popup window will come


Select Microsoft SQL Server and as the Data Provider select .Net Framework Data Provider for SQL Server.


Select or type the SQL server for Serer name drop down box.
Select or enter a Database name

For testing click the test connection button. and if connection is ok, press the ok button.
Connection will create with SQL selected database and you can see the tables in the database.
Now you can select the Table which you are need to bind with Gridview, also select the fields need to show with Griview.

Customizing the Griview you can watch with Video Chick here


Read More
// // Leave a Comment

How to create new project with visual studio 2010 VB


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


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 Visual Basic . 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