Group Discounts available for 3+ students and Corporate Clients

Filtering the Data based on LINQ queries in vb.net

Filtering the Data based on LINQ queries

 

Screenshot_71

 

Take 3×1 table Write available categories

Drag & drop DropDownList

Drag & drop Grid View Control & set width Autoformat

Drag & drop LINQDataSource & set width Autoformat

Select LINQDataSource task & configure Database

Category Id

Category Name

For DropDown List: Choose DataSource: LINQDataSource

Untitled Category Name

For dropdown list: ddl available

AutoPostball: true

Double click on Dropdown list

NorthWind DBDataContext dc = new NorthWindDBDataContext ();

Int cid = int.Parse (ddlCategories.SelectedItem.Value;

Var products = from product in dc.Products

Where

Product.Category Id = cid

Select new

?

Product.Product Id,

Product.ProductName,

Product = QuantityPerUnit,

Product.UnitPrice

};

GridView1.DataSource = Products;

GridView1.DataBind ();

Click on GridView tasks Untitled Edit columns à Uncheck auto generate fields

Select BoundField

Click Add

Header Text: Product ID

DataFile ID: Product ID

Select HyperLink Field

 

Add                HeaderText: ProductName

DataNavigateURI Fields: Product ID

DataNavigateURIFormatString: Showorders by Id.aspx ? pid = {0}

DataTextField: Product Name

Select Bound field

Add                Header Text: Quanity

DataField: Quanity per unit

Unit Price

Website (menu) – Add New Webform

Name: ShowOrdersby Id  Untitled  take 3×1 table

 

Screenshot_72

 

Select LINQ Data Source tab Untitled Table: Order_details

Select:

Screenshot_73

Screenshot_74

 

Select Grid View tasks:

ChooseDataSource: LINQDataSource

Click on edit columns

Command Field Untitled select Untitled add

Button Type: buttonUntitledSelect Text: Show Customer

OK

 

Observation:

The data from Grid View can be read from 3 different event handles.

  • From the event handlers of external controls
  • From the selected Index changed event of Grid View (select [Command Field])
  • From any events of Grid View other  than selected Index changed

 

To refer the Grid View row from selected Index changed event of Grid View:

Grid View name.Selected Row

To refer the Grid View Row from the events of Grid View other than Selected Index Changed;

e.Row (where “e” is a Grid View Row Event Args variable)

 

Note:

Data within the Grid View Row will exist within the table cell of Grid View Row or within some control present within the table cell of Grid View Row.

 

To read the Data from the Table cell of Grid View Row:

(Table cell) Grid View Row. Cells [cell index]

To read the value from the control present within the Tablecell of GridViewRow

(Control Type) GridViewRow. Cells [cellindex]. Controls [Control index]

(Or)

(Control Type) GridViewRow. Cells [cellindex]. Find Control [Control Name]

Untitled If we check 101 and list delete it must be deleted (Check Box)

Gvl.Rows[0].Cells [0].Find Control (chkOrderId)

 

// Double click on GridView

NorthWindDBDataContext dc = new NorthWindDBDataContext ();

Table oid = (Tablecell) GridView1.SelectedRow.Cells [0];

Int OrderId = int Parse (oid.Text)

Var cinfo = from customer in

dc.Orders where customer.OrderID = = OrderID

Select new

{

Customer.Customer.CompanyName,

Customer.Customer.ContextName,

Customer.Customer.CustomerID,

Customer.Customer.Country

} ;

GridView2.DataSource = cinfo;

GridView2.DataBind ();

Untitled Execute

 

“At TekSlate, we are trying to create high quality tutorials and articles, if you think any information is incorrect or want to add anything to the article, please feel free to get in touch with us at info@tekslate.com, we will update the article in 24 hours.”

0 Responses on Filtering the Data based on LINQ queries in vb.net"

    Leave a Message

    Your email address will not be published. Required fields are marked *

    Support


    Please Enter Your Details and Query.
    Three + 6