如何在每行的下拉列表中显示不同的值,其中行下拉值取决于同一行的其他列值。 [英] How to display different values in drop downs for each row, where row drop down values are dependent on other column value of same row.

查看:108
本文介绍了如何在每行的下拉列表中显示不同的值,其中行下拉值取决于同一行的其他列值。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Janus GridEx我创建了一个Grid,它有几个Columns,其中第9列(Code)将具有Drop Down,并且下拉列表中的数据对于不同的行应该是不同的,并且下拉值取决于第10列(CommentQID)值。



但是,现在我获得了每行所有下拉列表的相同值。请根据第10列(CommentQID)值向我建议更改以实现不同行的不同下拉值。



我尝试过:



Private Sub UpdateCodeDropdown()

Dim rows As Janus.Windows.GridEX.GridEXRow()

Dim row As Janus.Windows.GridEX.GridEXRow

Dim totRows As Integer = 0,iProofed As Integer = 0,iCoded As Integer = 0

Dim commentQID As Integer = 0

Dim i As Integer = 0

尝试

rows = grdProofCodeComments.GetRows()

For Each row In行

如果是row.Cells(CommentQID)。Text.ToString()IsNot Nothing AndAlso row.Cells(CommentQID)。Text.ToString()<> String.Empty然后

commentQID = row.Cells(CommentQID)。值

getCodes(commentQID)

否则:commentQID = 0

grdProofCodeComments.DropDowns(ddCommentCodeQID)。ClearItems()

结束如果



下一页

Catch ex As Exception

MessageBox.Show(ex.Message,UpdateStats中的错误,MessageBoxButtons.OK,MessageBoxIcon.Error)

最后

行=没有

结束尝试

结束子





Public Sub getCodes(commentQID As Integer)

Dim sqlCommand As String =SELECT ad.ADefID,ad.AOrder,ad.ADEValue,AValue = dbo.ufn_GetZeroFilledADeValue(a& _

d.ADefID,ad.ADesc,ad.ADescBrief FROM tblQDef q INNER JOIN tblADef ad on ad.AT& _ID = q.ATID WHERE(q.QID = @QID)

如果commentQID<>什么都没有

Dim ds As DataSet = SqlHelper.ExecuteDataset(ConnectionString,CommandType.Text,sqlCommand,New SqlParameter(@ QID,Convert.ToInt32(commentQID)))'如何传递整数数据类型SQL参数

grdProofCodeComments.DropDowns(ddCommentCodeQID)。SetDataBinding(ds,ds.Tables(0).TableName)

结束如果

End Sub

Using Janus GridEx I created a Grid, it is having few Columns where 9th column (Code) will have a Drop Down and the data in the drop down should be different for different rows, and the drop down values are dependent on the 10th column(CommentQID) value.

But, now I am getting the same values for all drop downs in every row. Please suggest me the changes to achieve different drop down values for different row based on 10th column(CommentQID) value.

What I have tried:

Private Sub UpdateCodeDropdown()
Dim rows As Janus.Windows.GridEX.GridEXRow()
Dim row As Janus.Windows.GridEX.GridEXRow
Dim totRows As Integer = 0, iProofed As Integer = 0, iCoded As Integer = 0
Dim commentQID As Integer = 0
Dim i As Integer = 0
Try
rows = grdProofCodeComments.GetRows()
For Each row In rows
If row.Cells("CommentQID").Text.ToString() IsNot Nothing AndAlso row.Cells("CommentQID").Text.ToString() <> String.Empty Then
commentQID = row.Cells("CommentQID").Value
getCodes(commentQID)
Else : commentQID = 0
grdProofCodeComments.DropDowns("ddCommentCodeQID").ClearItems()
End If

Next
Catch ex As Exception
MessageBox.Show(ex.Message, "Error in UpdateStats", MessageBoxButtons.OK, MessageBoxIcon.Error)
Finally
rows = Nothing
End Try
End Sub


Public Sub getCodes(commentQID As Integer)
Dim sqlCommand As String = "SELECT ad.ADefID, ad.AOrder, ad.ADEValue, AValue= dbo.ufn_GetZeroFilledADeValue(a" & _
"d.ADefID), ad.ADesc, ad.ADescBrief FROM tblQDef q INNER JOIN tblADef ad ON ad.AT" & _"ID = q.ATID WHERE (q.QID = @QID)"
If commentQID <> Nothing Then
Dim ds As DataSet = SqlHelper.ExecuteDataset(ConnectionString, CommandType.Text, sqlCommand, New SqlParameter("@QID", Convert.ToInt32(commentQID))) 'how to pass the integer datatype SQL parameter
grdProofCodeComments.DropDowns("ddCommentCodeQID").SetDataBinding(ds, ds.Tables(0).TableName)
End If
End Sub

推荐答案

最好将下拉列表与绑定源绑定,并将dataproertyName设置为将获取所选值的Id,并设置Valuemember并显示Member。

然后在load事件中填充此bindingSource.datasource
It is better to bind your dropdown with binding source and set the dataproertyName to the Id that will get the selected value and set the Valuemember and display Member.
Then fill this bindingSource.datasource in the load event


这篇关于如何在每行的下拉列表中显示不同的值,其中行下拉值取决于同一行的其他列值。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆