|
-
Sep 27th, 2010, 09:22 AM
#1
Thread Starter
PowerPoster
[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,
-
Sep 27th, 2010, 09:25 AM
#2
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
-
Sep 27th, 2010, 09:41 AM
#3
Re: Using the DataList WebControl?
Can you show the code, both the ASPX markup and the code that you are using?
Gary
-
Sep 27th, 2010, 09:48 AM
#4
Thread Starter
PowerPoster
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:
<%@ 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>
-
Sep 27th, 2010, 09:56 AM
#5
Re: Using the DataList WebControl?
Where are you setting the DataSource property of the DataList?
Gary
-
Sep 27th, 2010, 10:06 AM
#6
Thread Starter
PowerPoster
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:
<%@ 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>
-
Sep 27th, 2010, 02:37 PM
#7
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
-
Sep 27th, 2010, 03:23 PM
#8
Thread Starter
PowerPoster
Re: Using the DataList WebControl?
Thanks Gary...I'll take a peek at it!
-
Sep 28th, 2010, 01:36 AM
#9
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
-
Sep 28th, 2010, 08:54 AM
#10
Thread Starter
PowerPoster
Re: [RESOLVED] Using the DataList WebControl?
I did get it working Gary, however, I went to a RadioButtonList which worked great!
Thanks,
-
Sep 28th, 2010, 09:23 AM
#11
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|