Click here to Skip to main content
15,899,313 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: library or application name Pin
Marc Soleda24-Jan-07 21:43
Marc Soleda24-Jan-07 21:43 
QuestionBinding A Form with MDI form Pin
Zashir24-Jan-07 0:31
Zashir24-Jan-07 0:31 
QuestionForm within a balloon or similar Pin
Dave McCool24-Jan-07 0:27
Dave McCool24-Jan-07 0:27 
QuestionDatagridView Pin
Socheat.Net24-Jan-07 0:13
Socheat.Net24-Jan-07 0:13 
AnswerRe: DatagridView Pin
Ahmed El-Badry24-Jan-07 1:06
Ahmed El-Badry24-Jan-07 1:06 
QuestionPlz help me Pin
Ahmed El-Badry24-Jan-07 0:07
Ahmed El-Badry24-Jan-07 0:07 
Questionhow to add comboBox as a column in DatagridView? Pin
priya_p23324-Jan-07 0:01
priya_p23324-Jan-07 0:01 
AnswerRe: how to add comboBox as a column in DatagridView? Pin
tonymathewt24-Jan-07 1:44
professionaltonymathewt24-Jan-07 1:44 
First you have to fill the dataset as done in the below getdataset(). Then in the rowdatabound event of the Gridview bind Dropdownlist with the dataset. In the page_load event you only need to bind the GridView.


'Function to fill the dataset
Private Function getdataset() As DataSet
Dim connectionstring As String = "Data Source=localhost;Initial Catalog=northwind;User ID=sa;password="
Dim query As String = "select p.categoryid,p.productid, p.productname,c.categoryid,c.categoryname from products p,categories c where p.categoryid=c.categoryid and c.categoryid<3"
Dim myconnection As New SqlConnection(connectionstring)
Dim ad As New SqlDataAdapter(query, myconnection)
Dim ds As New DataSet()
ad.Fill(ds)
Return ds
End Function 'getdataset
******************************************************************************

'Code in rowdatabound event to bind DropDownList to GridView
Protected Sub gridview1_rowdatabound(sender As Object, e As GridViewRowEventArgs)
Dim mytable As New DataTable()
Dim productidcolumn As New DataColumn("productid")
Dim productnamecolumn As New DataColumn("productname")

mytable.Columns.Add(productidcolumn)
mytable.Columns.Add(productnamecolumn)

Dim ds As New DataSet()
ds = getdataset()
Dim categoryid As Integer = 0
Dim expression As String = String.Empty

If e.Row.RowType = DataControlRowType.DataRow Then
categoryid = Int32.Parse(e.Row.Cells(0).Text)
expression = "categoryid = " + categoryid
Dim ddl As DropDownList = CType(e.Row.FindControl("dropdownlist1"), DropDownList)
Dim rows As DataRow() = ds.Tables(0).Select(expression)

Dim row As DataRow
For Each row In rows
Dim newrow As DataRow = mytable.NewRow()
newrow("productid") = row("productid")
newrow("productname") = row("productname")
mytable.Rows.Add(newrow)
Next row

ddl.DataSource = mytable
ddl.DataTextField = "productname"
ddl.DataValueField = "productid"
ddl.DataBind()
End If
End Sub 'gridview1_rowdatabound
******************************************************************************
'Page Load event

Protected Sub Page_Load(sender As Object, e As EventArgs)
gridview1.DataSource = getdataset().Tables(0)
gridview1.DataBind()
End Sub 'Page_Load
******************************************************************************

{Souce}



GridviewNestingDropdowlist
<asp:gridview id="gridview1" runat="server" autogeneratecolumns="False" onrowdatabound="gridview1_rowdatabound">
<columns><asp:boundfield datafield="categoryid" headertext="categoryid">
<asp:boundfield datafield="categoryname" headertext="category name">
<asp:boundfield datafield="productid" headertext="productid">
<asp:templatefield headertext="products">
<itemtemplate>
<asp:dropdownlist id="dropdownlist1" runat="server">






GeneralRe: how to add comboBox as a column in DatagridView? Pin
priya_p23324-Jan-07 18:15
priya_p23324-Jan-07 18:15 
AnswerRe: how to add comboBox as a column in DatagridView? [modified] Pin
atulks.in24-Jan-07 20:18
atulks.in24-Jan-07 20:18 
AnswerRe: how to add comboBox as a column in DatagridView? Pin
tonymathewt24-Jan-07 22:43
professionaltonymathewt24-Jan-07 22:43 
QuestionDatabase error Pin
lanache23-Jan-07 23:58
lanache23-Jan-07 23:58 
AnswerRe: Database error Pin
atulks.in24-Jan-07 19:49
atulks.in24-Jan-07 19:49 
GeneralRe: Database error Pin
lanache24-Jan-07 23:04
lanache24-Jan-07 23:04 
AnswerRe: Database error Pin
atulks.in25-Jan-07 0:11
atulks.in25-Jan-07 0:11 
QuestionDatabase error Pin
lanache23-Jan-07 23:47
lanache23-Jan-07 23:47 
AnswerRe: Database error Pin
Ahmed El-Badry24-Jan-07 0:39
Ahmed El-Badry24-Jan-07 0:39 
GeneralRe: Database error Pin
lanache24-Jan-07 22:20
lanache24-Jan-07 22:20 
QuestionIs this possible??????? Pin
FeRtoll23-Jan-07 22:52
FeRtoll23-Jan-07 22:52 
AnswerRe: Is this possible??????? Pin
IqbalVB25-Jan-07 20:03
IqbalVB25-Jan-07 20:03 
GeneralRe: Is this possible??????? Pin
FeRtoll28-Jan-07 23:21
FeRtoll28-Jan-07 23:21 
Questioncreating a batch file to generate dll from code files of vb6 and vb.net Pin
atulks.in23-Jan-07 22:19
atulks.in23-Jan-07 22:19 
AnswerRe: creating a batch file to generate dll from code files of vb6 and vb.net Pin
Ahmed El-Badry24-Jan-07 0:42
Ahmed El-Badry24-Jan-07 0:42 
GeneralRe: creating a batch file to generate dll from code files of vb6 and vb.net Pin
atulks.in24-Jan-07 19:41
atulks.in24-Jan-07 19:41 
QuestionFile Watcher Question Pin
FeRtoll23-Jan-07 21:37
FeRtoll23-Jan-07 21:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.