GridView with Nested ComboBox

Hello to all readers.
(Seeing it contains ASP.Net code and mainly ASP.Net with VB.Net code behind)

You have a store and like to order a couple of new items for your store, so naturally you will need an order form to be filled in.

Requirements on the form are:
ID number of the product (IcnNumber)
Product description

When the form loads ONLY ONE datagrid row must be visible with the controls combobox (IcnNumber flied), label(description label) and textbox (quantity field). Then a button is clicked to add a new row with the same controls as before that can be filled in by the user to order the items.

[size=4]ASP.Net Code[/size]
<%@ Page Title="" Language="vb" AutoEventWireup="false" CodeBehind="WebForm1.aspx.vb"
Inherits="WebApplication1.WebForm1" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajax" %>

GridView RowDataBound Example


[size=4]VB.Net Code Behind[/size]
Imports System.Configuration.ConfigurationManager
Imports AjaxControlToolkit

Public Class WebForm1
Inherits System.Web.UI.Page

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
IcnDataSource.DataSourceMode = SqlDataSourceMode.DataReader
IcnDataSource.ConnectionString = ConnectionStrings("PatientMISConnectionString").ConnectionString
IcnDataSource.SelectCommand = "SELECT top(5) ItemId,IcnNumber FROM dbo.Items"
End Sub

Protected Sub OrderGridView_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs)
Dim drdList As ComboBox
For Each rowItem As GridViewRow In PersonGridView.Rows
drdList = CType(rowItem.Cells(0).FindControl("cboIcnNumber"), ComboBox)
drdList.DataSource = IcnDataSource
drdList.DataTextField = "IcnNumber"
drdList.DataValueField = "ItemId"
End Sub
End Class

[size=4]The problem[/size]
I have no idea on how to get ONLY ONE row visible to be filled in and the button ,can be any ware on the form, that can be click to add a new row.


I can get the combobox to populate and that is about all that I can do.

Now this is all done with ASP.Net, VB.Net, Visual Studio 2010, Framework 4 and
[link=]AjaxControlToolkit [/link] version 4.1.50401

I have attached an .zip file ( that contains 2 files
1 x Preview.jpg = This is just to show what the result is from the above code

1 x WebForm1.aspx = just to help with the layout and not copy and past the code

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!