Results 1 to 11 of 11

Thread: [RESOLVED] Using the DataList WebControl?

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    5,034

    Resolved [RESOLVED] Using the DataList WebControl?

    I'm using the DataList WebControl for the first time. What I am wanting to do is dynamically load a datalist bound to a datasource with radiobuttons. This datalist control resides within a <div>. In design mode, everything looks great, however, when I run my web app...nothing appears. Do I need to associate the datalist control to the div by chance? I'm just not sure and I couldn't find any documentation that would lead me to believe that.

    Thanks,
    Blake

  2. #2
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: Using the DataList WebControl?

    Did you check the view source of that page, did the list showed up there ?
    Please mark you thread resolved using the Thread Tools as shown

  3. #3
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Using the DataList WebControl?

    Can you show the code, both the ASPX markup and the code that you are using?

    Gary

  4. #4

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    5,034

    Re: Using the DataList WebControl?

    What are you referring to when you say "viewsource"?

    Here is my markup! The only thing that shows up in the Design Mode are the 2 sqlDataSources.

    HTML Code:
    <&#37;@ Page Language="vb" AutoEventWireup="false" CodeBehind="Default.aspx.vb" Inherits="WebApplication1._Default" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
            <asp:Table ID="Table1" runat="server">
                <asp:TableRow runat="server" Width="100%">
                    <asp:TableCell runat="server" Width="30%">
                        <asp:DataList ID="ddlGender" runat="server" RepeatColumns="3" RepeatDirection="Horizontal">
                            <ItemTemplate>
                                <asp:RadioButton ID="rdoGender" runat="server" style="padding:7px;"
                                text='<%# DataBinder.Eval(Container.DataItem,"Band_Value_Name") %>'/>
                            </ItemTemplate>
                        </asp:DataList>  
                    </asp:TableCell>
    
                    <asp:TableCell runat="server" Width="65%">
                        <asp:DataList ID="ddlFamilyComp" runat="server" RepeatColumns="5" RepeatDirection="Horizontal">
                            <ItemTemplate>
                                <asp:RadioButton id="rdoFamilyComp" runat="server" style="padding:7px;"
                                     text='<%# DataBinder.Eval(Container.DataItem,"Band_Value_Name") %>'></asp:RadioButton>
                            </ItemTemplate>
                        </asp:DataList>
                    </asp:TableCell>
                </asp:TableRow>
            </asp:Table>
    
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
            ConnectionString="<%$ ConnectionStrings:OA_ConfigurationConnectionString %>" 
            SelectCommand="SELECT [Band_Value_Name] FROM [Band_Value_Bkup] WHERE ([Band_ID] = @Band_ID)">
            <SelectParameters>
                <asp:Parameter DefaultValue="4" Name="Band_ID" Type="Int32" />
            </SelectParameters>
        </asp:SqlDataSource>
        <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
            ConnectionString="<%$ ConnectionStrings:OA_ConfigurationConnectionString %>" 
            SelectCommand="SELECT [Band_Value_Name] FROM [Band_Value_Bkup] WHERE ([Band_ID] = @Band_ID)">
            <SelectParameters>
                <asp:Parameter DefaultValue="3" Name="Band_ID" Type="Int32" />
            </SelectParameters>
        </asp:SqlDataSource>
        </form>
    </body>
    </html>
    Blake

  5. #5
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Using the DataList WebControl?

    Where are you setting the DataSource property of the DataList?

    Gary

  6. #6

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    5,034

    Re: Using the DataList WebControl?

    Gary,

    I guess I'm not. I thought by using the RadioButtons and then assigning a datasource to the RadioButtons was accomplishing that. I'm using 2 SqlDataSources. I just tried setting the DataSource property of both DataLists to the appropriate SqlDataSources. When I ran the app, I got the error message "The 'DataSource' property cannot be set declaratively". Here is the updated markup:

    HTML Code:
    <&#37;@ Page Language="vb" AutoEventWireup="false" CodeBehind="Default.aspx.vb" Inherits="WebApplication1._Default" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
            <asp:Table ID="Table1" runat="server">
                <asp:TableRow runat="server" Width="100%">
                    <asp:TableCell runat="server" Width="30%">
                        <asp:DataList ID="ddlGender" runat="server" DataSource="SqlDataSource2" RepeatColumns="3" RepeatDirection="Horizontal">
                            <ItemTemplate>
                                <asp:RadioButton ID="rdoGender" runat="server" style="padding:7px;"
                                text='<%# DataBinder.Eval(Container.DataItem,"Band_Value_Name") %>'/>
                            </ItemTemplate>
                        </asp:DataList>  
                    </asp:TableCell>
    
                    <asp:TableCell runat="server" Width="65%">
                        <asp:DataList ID="ddlFamilyComp" runat="server" DataSource="SqlDataSource1 RepeatColumns="5" RepeatDirection="Horizontal">
                            <ItemTemplate>
                                <asp:RadioButton id="rdoFamilyComp" runat="server" style="padding:7px;"
                                     text='<%# DataBinder.Eval(Container.DataItem,"Band_Value_Name") %>'></asp:RadioButton>
                            </ItemTemplate>
                        </asp:DataList>
                    </asp:TableCell>
                </asp:TableRow>
            </asp:Table>
    
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
            ConnectionString="<%$ ConnectionStrings:OA_ConfigurationConnectionString %>" 
            SelectCommand="SELECT [Band_Value_Name] FROM [Band_Value_Bkup] WHERE ([Band_ID] = @Band_ID)">
            <SelectParameters>
                <asp:Parameter DefaultValue="4" Name="Band_ID" Type="Int32" />
            </SelectParameters>
        </asp:SqlDataSource>
        <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
            ConnectionString="<%$ ConnectionStrings:OA_ConfigurationConnectionString %>" 
            SelectCommand="SELECT [Band_Value_Name] FROM [Band_Value_Bkup] WHERE ([Band_ID] = @Band_ID)">
            <SelectParameters>
                <asp:Parameter DefaultValue="3" Name="Band_ID" Type="Int32" />
            </SelectParameters>
        </asp:SqlDataSource>
        </form>
    </body>
    </html>
    Blake

  7. #7
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Using the DataList WebControl?

    Hey,

    You can find the documentation for the DataList here:

    http://msdn.microsoft.com/en-us/libr...(v=VS.85).aspx

    Trying doing this in the server side code:

    Code:
    Me.ddlGender = Me.SqlDataSource2
    Gary

  8. #8

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    5,034

    Re: Using the DataList WebControl?

    Thanks Gary...I'll take a peek at it!
    Blake

  9. #9
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: [RESOLVED] Using the DataList WebControl?

    Did you get this working Blake? I see you have marked the thread resolved.

    Did setting the DataSource in the code behind work for you?

    Gary

  10. #10

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    5,034

    Re: [RESOLVED] Using the DataList WebControl?

    I did get it working Gary, however, I went to a RadioButtonList which worked great!

    Thanks,
    Blake

  11. #11
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: [RESOLVED] Using the DataList WebControl?

    Ah, yes, I read your other thread after I posted in this one.

    Gary

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width