when i use the autogeneratecolumns = false some columns are not bindined to datagridview If i click on between Button and ComboBox

Viewed 21

Actually i have a Combo Box and button in my application .In this Appn I used autogeneratecolumns = false and i added some columns to datagridview with datapropertyname in the Button. First time When i click the button it properly Binding but When i select Combo Box After button click some columns of query related data is not binding.

Note:Whatever i mentioned the columns with datapropertyname is not binding in datagridview when i select Combo box. Vb.net

Dim cmd As New SqlCommand("SELECT * FROM Queries where Querys like '%" + ddlQuerys.Text + "%'", con)
 cmd.CommandType = CommandType.Text
                Dim sda As New SqlDataAdapter(cmd)
                Dim ds As New DataSet()
                gvInsuredData.Columns(0).Visible = True
                gvInsuredData.Columns(1).Visible = True
                sda.Fill(ds)
 gvInsuredData.AutoGenerateColumns = False
                gvInsuredData.DataSource = dt

   gvInsuredData.Columns(2).Name = "personalPropertyItemID"
                gvInsuredData.Columns(2).HeaderText = " Item ID"
                gvInsuredData.Columns(2).DataPropertyName = "personalPropertyItemID"

                gvInsuredData.Columns(3).Name = "personalPropertyQuantity"
                gvInsuredData.Columns(3).HeaderText = "Qty"
                gvInsuredData.Columns(3).DataPropertyName = "personalPropertyQuantity"

                gvInsuredData.Columns(7).Name = "Age(y)"
                gvInsuredData.Columns(7).HeaderText = "Age(y)"
                gvInsuredData.Columns(7).DataPropertyName = "personalPropertyAge"

                gvInsuredData.Columns(8).Name = "Age(m)"
                gvInsuredData.Columns(8).HeaderText = "Age(m)"
                gvInsuredData.Columns(8).DataPropertyName = "Personalpropertyagem"


                gvInsuredData.Columns(9).Name = "Unit Cost"
                gvInsuredData.Columns(9).HeaderText = "Unit Cost"
                gvInsuredData.Columns(9).DataPropertyName = "personalPropertyCost"

                gvInsuredData.Columns(10).Name = "Total Cost"
                gvInsuredData.Columns(10).HeaderText = "Total Cost"
                gvInsuredData.Columns(10).DataPropertyName = "PersonalPropertyTotalCost"


                Dim AytC As Keyoti.RapidSpell.Grid.AYTDataGridViewTextBoxColumn = New Keyoti.RapidSpell.Grid.AYTDataGridViewTextBoxColumn()
                AytC.HeaderText = "DescriptionProperty"
                AytC.Name = "Description"
                AytC.DataPropertyName = "personalPropertyDescription"
                gvInsuredData.Columns(5).DataPropertyName = "personalPropertyDescription"
                gvInsuredData.DataSource = ds.Tables(0)

                Dim AytCtb As Keyoti.RapidSpell.Grid.AYTDataGridViewTextBoxColumn = New Keyoti.RapidSpell.Grid.AYTDataGridViewTextBoxColumn()
                AytCtb.HeaderText = "SourceProperty"
                AytCtb.Name = "Source"
                gvInsuredData.Columns(6).DataPropertyName = "personalPropertySource"
                gvInsuredData.DataSource = ds.Tables(0)

Item ID,Qty,Age(Y),Age(m),unit cost and total cost columns are not binding when i select combobox but other columns data is binding

1 Answers

I'm not 100% sure that this is the issue but it looks awfully suspicious. You create a populate a DataSet named ds:

Dim ds As New DataSet()
'...
sda.Fill(ds)

but then you assign a dt variable that appears nowhere else in your code to the grid's DataSource:

gvInsuredData.DataSource = dt

What's up with that? Why are you creating a DataSet at all when all you need is a DataTable? I assume that dt is at least supposed to be type DataTable but where did it come from? Did you leave out some relevant code or are you actually not assigning the data source that you think you are?

Related