Radgrid FormTemplate 内的 Radcombobox

发布于 2024-10-03 01:47:20 字数 753 浏览 0 评论 0原文

天哪,

我在 RadGrid 中有一个 RadComboBox 控件,当 InitInsert 操作发生时会显示该控件。我使用实体框架作为数据源&其中包含的结果是正确的。我的问题是,当我使用 findcontrol 时它什么也不返回。

如果 e.CommandName = "InitInsert" 那么 RadGrid1.MasterTableView.InsertItemDisplay = Telerik.Web.UI.GridInsertItemDisplay.Bottom Dim query = From myTable In dbEntity.myTables Select myTable.Name, myTable.ID

        Dim mineCompBox = CType(e.Item.FindControl("mineCompBox"), RadComboBox)
        mineCompBox.DataSource = mineCompQuery
        mineCompRadBox.DataTextField = "Name"
        mineCompRadBox.DataValueField = "Id"
        mineCompRadBox.DataBind()</code>

我无法找到引用 FormTemplate 而不是编辑表单的任何答案。我缺少什么? :-(

谢谢。

G'day,

I have a RadComboBox control inside of a RadGrid that is displayed when the InitInsert action occurs. I'm using Entity Framework as a datasource & the results contained within this are correct. My problem is that when I use findcontrol it returns nothing.

If e.CommandName = "InitInsert" Then
RadGrid1.MasterTableView.InsertItemDisplay = Telerik.Web.UI.GridInsertItemDisplay.Bottom
Dim query = From myTable In dbEntity.myTables Select myTable.Name, myTable.ID

        Dim mineCompBox = CType(e.Item.FindControl("mineCompBox"), RadComboBox)
        mineCompBox.DataSource = mineCompQuery
        mineCompRadBox.DataTextField = "Name"
        mineCompRadBox.DataValueField = "Id"
        mineCompRadBox.DataBind()</code>

I'm having trouble finding any answers that reference FormTemplate without it being an edit form. What am I missing? :-(

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

输什么也不输骨气 2024-10-10 01:47:20

我面前没有电脑来测试它,但我很确定:
1)你没有看到正确的控件集合
2) 或 RadComboBox 尚未创建或已创建但 ID 不匹配
所以你找不到它

,也不是100%确定。也许这可以帮助您它的完整示例: http:// /beecy.net/post/2009/01/07/telerik-radgrid-formtemplate-codebehind.aspx (也许可以根据此检查您的标记)

I don't have my computer in front of me to test it but I'm pretty sure that either:
1) You are not looking at the right controls collection
2) or the RadComboBox is not create yet or has been created but the ID doesn't match
so you cannot find it

Again not 100% sure. Maybe this can help you its a complete example: http://beecy.net/post/2009/01/07/telerik-radgrid-formtemplate-codebehind.aspx (maybe check you markup against this one)

羁客 2024-10-10 01:47:20

我的问题是通过使用 ItemCreated 命令解决的。可以在此处找到示例:

http://www.telerik.com/community/forums/aspnet-ajax/grid/find-controls-when-using-editcommand.aspx

我的情况的代码是:

Private Sub RadGrid1_ItemCreated(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles RadGrid1.ItemCreated
    If TypeOf e.Item Is GridEditFormItem AndAlso e.Item.IsInEditMode Then
        Dim dbEntity As WebsiteEntities = New WebsiteEntities
        Dim myQuery = From myTable In myTables Select myTable.Name, myTable.ID
        Dim EditFormItem As GridEditFormItem = DirectCast(e.Item, GridEditFormItem)
        Dim myCombobox As RadComboBox = DirectCast(EditFormItem.FindControl("radDropBox"), RadComboBox)
        myCombobox.DataSource = myQuery
        myCombobox.DataTextField = "Name"
        myCombobox.DataValueField = "ID"
        myCombobox.DataBind()
    End If
End Sub

My problem was solved by using an ItemCreated command. An example can be found here:

http://www.telerik.com/community/forums/aspnet-ajax/grid/find-controls-when-using-editcommand.aspx

The code for my situation was:

Private Sub RadGrid1_ItemCreated(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles RadGrid1.ItemCreated
    If TypeOf e.Item Is GridEditFormItem AndAlso e.Item.IsInEditMode Then
        Dim dbEntity As WebsiteEntities = New WebsiteEntities
        Dim myQuery = From myTable In myTables Select myTable.Name, myTable.ID
        Dim EditFormItem As GridEditFormItem = DirectCast(e.Item, GridEditFormItem)
        Dim myCombobox As RadComboBox = DirectCast(EditFormItem.FindControl("radDropBox"), RadComboBox)
        myCombobox.DataSource = myQuery
        myCombobox.DataTextField = "Name"
        myCombobox.DataValueField = "ID"
        myCombobox.DataBind()
    End If
End Sub
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文