Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Datalist Problem 1

Status
Not open for further replies.

1Data

MIS
Sep 30, 2005
66
US
I having problem displays my information in a Datalist. It displays the Header Template but no data, I am setting the source and bind (Code Behind) to a SqlReader that is reading fine but for some reason I can't see it in my Datalist. I did a Response.Write on my Reader to make certain that it contains the right information, it does. Here is my HTML code for my DataReader and my Code Behind:

HTML Code...
<asp:datalist id="Datalist" runat="server" BorderColor="black" Width="696px" Visible="False" OnEditCommand="DataList_EditCommand"

EditItemStyle-BackColor="lightgreen" AlternatingItemStyle-BackColor="Gainsboro" HeaderStyle-BackColor="LightSteelBlue"
Font-Size="8pt" Font-Name="Verdana" CellSpacing="0" CellPadding="3" GridLines="Both" BorderWidth="1">

<HeaderTemplate>
<b>Select Volunteer:</b>
</HeaderTemplate>

<EditItemStyle BackColor="LightGreen"></EditItemStyle>
<AlternatingItemStyle BackColor="Gainsboro"></AlternatingItemStyle>

<ItemTemplate><asp:LinkButton id="Linkbutton6" runat="server" Text="Select" CommandName="edit">

</asp:LinkButton><I>&nbsp;&nbsp;<%# DataBinder.Eval(Container.DataItem, "ssn_mask")%>&nbsp;&nbsp;&nbsp;&nbsp;<%# DataBinder.Eval(Container.DataItem, "last")%>,&nbsp;<%# DataBinder.Eval(Container.DataItem, "first")%>&nbsp;<%# DataBinder.Eval(Container.DataItem, "middle")%></I>

<asp:TextBox id="Textbox21" visible=False runat="server" text='<%# DataBinder.Eval(Container.DataItem, "ssn") %>'>

</asp:TextBox><asp:TextBox id="Textbox22" visible=False runat="server" text='<%# DataBinder.Eval(Container.DataItem, "new_applicant") %>'>
</asp:TextBox>

<asp:Label ForeColor=#ff3300 Runat="server" ID="lblRenewal" Text=" * Renewal Needed" visible='<%# CheckStatus(DataBinder.Eval(Container.DataItem, "renewal"))%>'>
</asp:Label>
</ItemTemplate>
<HeaderStyle BackColor="LightSteelBlue"></HeaderStyle>
</asp:datalist>

(Code Behind) - I step through it and works fine...
ElseIf Session("User_org") = "0" Then
Datalist.DataSource = dm
Datalist.DataBind()
Datalist.Visible = True
txtSSN.Text = ""
txtlname.Text = ""
ButAdd.Visible = False
ButtryAgain.Visible = False
lblFound.Visible = False

I always thought that as long as you bind the datalist and there is data present it will display the information...
I've been staring at this for a couple of hours and can't see what the problem is...if there is anyone that can offer some suggestions I would appreciate it...thanks in advance.
 
You should just be able to Bind to the DataReader, however, if you've already read the data then it won't bind (I'm not sure if this is the case or not). You may also have to set the DataMember of the DataList so it may actually be worthwhile using a DataTable rather than a DataReader.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
I had dm.Read() before my Elseif Statement...thanks a million.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top