Howdy, Stranger!

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

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

GridView with Nested ComboBox

Hav0c1Hav0c1 Posts: 1Member
Hello to all readers.
(Seeing it contains ASP.Net code and mainly ASP.Net with VB.Net code behind)

Scenario:
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
Quantity

Desire:
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]
[code]
<%@ Page Title="" Language="vb" AutoEventWireup="false" CodeBehind="WebForm1.aspx.vb"
Inherits="WebApplication1.WebForm1" %>

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



GridView RowDataBound Example
































[/code]

[size=4]VB.Net Code Behind[/size]
[code]
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"
drdList.DataBind()
Next
End Sub
End Class
[/code]

[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.

[size=4]Information[/size]

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=http://ajaxcontroltoolkit.codeplex.com/releases/view/63654]AjaxControlToolkit [/link] version 4.1.50401

I have attached an .zip file (Code.zip) 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

Regards
Hav0c
Sign In or Register to comment.