English 中文(简体)
在数据Grid中反复出现的下降箱
原标题:Populate repeated dropdown box in DataGrid

我正试图把一个VB.net下滴盒填入一个数据网。 基本上,我有一幅图像,用户需要从降幅清单中挑选该物品,这样我就可以在数据库中挽救它。

Dim DDLPlayColorList = New DropDownList
DDLPlayColorList = dgImages.FindControl("DDLPlayColorList")

Using oConn As New SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString)
    Using cmd As New SqlCommand("doGetAllPlayColours", oConn)
        cmd.CommandType = CommandType.StoredProcedure
        oConn.Open()
        Using dr As SqlDataReader = cmd.ExecuteReader()
            DDLPlayColorList.DataSource = dr
            DDLPlayColorList.DataTextField = "playColour"
            DDLPlayColorList.DataValueField = "playColour"
            DDLPlayColorList.DataBind()
        End Using
    End Using
End Using

我试图利用发现控制功能来发现控制,然后对控制加以约束,但并没有改变。 错误

DDLPlayColorList不是经理成员。

This is my DataGrid:

<asp:DataGrid ID="dgImages" runat="server" Width="300" AutoGenerateColumns="false" ItemStyle-Width="300" ItemStyle-BorderWidth="3px">
    <Columns>
        <asp:TemplateColumn ItemStyle-BackColor="#eaeaea" ItemStyle-Width="100">
            <ItemTemplate>
                <a href="image.aspx?libid=<%#Container.DataItem("id")%>">
                    <asp:Image ID="imgCategoryThumb" CssClass="lightbox-thumb" runat="server" Height="100" Width="100" ImageUrl= <%#Container.DataItem("path")%>  AlternateText="" />
                </a>
                <asp:DropDownList id="DDLPlayColorList" runat="server" CssClass="textfield">
                </asp:DropDownList>
            </itemtemplate>
        </asp:TemplateColumn>
    </Columns>
</asp:DataGrid>
最佳回答

引证:

Dim DDLPlayColorList As DropDownList = CType(dgImages.FindControl("DDLPlayColorList"), DropDownList)

If DDLPlayColorList IsNot Nothing Then
    Using oConn As New SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString)
        Using cmd As New SqlCommand("doGetAllPlayColours", oConn)
            cmd.CommandType = CommandType.StoredProcedure
            oConn.Open()
            Using dr As SqlDataReader = cmd.ExecuteReader()
                DDLPlayColorList.DataSource = dr
                DDLPlayColorList.DataTextField = "playColour"
                DDLPlayColorList.DataValueField = "playColour"
                DDLPlayColorList.DataBind()

            End Using
        End Using
    End Using    
End If

在数据具有约束力时确定多重下降的识别资料:

private void OnItemDataBound(object sender, DataGridItemEventArgs e)
{
    if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
    {
        Dim DDLPlayColorList As DropDownList = CType(e.Item.FindControl("DDLPlayColorList"), DropDownList)
        DDLPlayColorList.ID = "DDLPlayColorList" & e.RowIndex.ToString()
    }
}
问题回答

暂无回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签