Jump to content

Display Content


softweb001

Recommended Posts

Hi......

 

I want to display the content of my database on a page in a div that will group them one by one and i want it to iterate through

 

somthing like this in php

 

while($row=mysql_fetch_assoc(#sql)){

echo "<div class='cont'>";

echo "$row['Names']";

echo "</div>";

}

 

i want to do this in c# .NET

 

Please help me out

 

 

Thanks...........

Link to comment
Share on other sites

This is d code behind

===================

 

void LoadProject() { FormsIdentity objTicket; objTicket = (FormsIdentity)User.Identity; string sUser = objTicket.Ticket.Name; string staffID = Session["Owner"].ToString(); sql = "Select * From Project_List Where Staff_ID=@staID And Status=@sTatus"; try { using (con = new SqlConnection(conString)) { con.Open(); cmd = new SqlCommand(sql, con); cmd.Parameters.Add("@staID", SqlDbType.VarChar).Value = staffID; cmd.Parameters.Add("@sTatus", SqlDbType.VarChar).Value = "Started"; SqlDataAdapter sda = new SqlDataAdapter(); sda.SelectCommand = cmd; sda.TableMappings.Add("Table", "recs"); DataSet set = new DataSet(); sda.Fill(set); int total = Convert.ToInt32(set.Tables[0].Rows.Count); if (total > 0) { SqlDataReader dtaReader = cmd.ExecuteReader(); dtlOngoing.DataSource = dtaReader; dtlOngoing.DataBind(); dtaReader.Close(); } else { lblMsg.Text = "No New project for this user!!!"; } } } catch (Exception ex) { lblMsg.Text = ex.Message.ToString(); } finally { con.Close(); } }

 

 

and this is the Design

===================

 

<asp:DataList CssClass="par2" ID="dtlOngoing" runat="server" OnCancelCommand="dl_Cancel" OnEditCommand="dl_Edit" OnUpdateCommand="dl_Update" DataKeyField="Project_ID"> <ItemStyle Font-Names="Times New Roman" Font-Size="10pt" ForeColor="Black" /> <AlternatingItemStyle BackColor="Red" /> <ItemTemplate> <p> Project Name:<strong> <%# DataBinder.Eval(Container.DataItem, "Project_Title") %> </strong><br /> </p> <p> Description:<strong> <%# DataBinder.Eval(Container.DataItem, "Description") %> </strong><br /> </p> <p> Status:<strong> <%# DataBinder.Eval(Container.DataItem, "Status") %> </strong> </p> <p> <asp:LinkButton ID="lbEdit" runat="server" Text="Edit" CommandName="Edit"></asp:LinkButton> </p> </ItemTemplate> <EditItemTemplate> <p> Project Name:<strong> <%# DataBinder.Eval(Container.DataItem, "Project_Title") %> </strong><br /> </p> <p> Description:<strong> <%# DataBinder.Eval(Container.DataItem, "Description") %> </strong><br /> </p> <p> Status: <asp:DropDownList ID="ddlStatus" runat="server"> <asp:ListItem Value="Started" Text="Started">Started</asp:ListItem> <asp:ListItem Value="Finished" Text="Finished">Finished</asp:ListItem> </asp:DropDownList><br /> <asp:LinkButton ID="lbCancel" runat="server" Text="Cancel" CommandName="Cancel"></asp:LinkButton>| <asp:LinkButton ID="lbUpdate" runat="server" Text="Update" CommandName="Update"></asp:LinkButton> </p> </EditItemTemplate> <SeparatorTemplate> <hr style=" border:5px solid double;" /> </SeparatorTemplate> </asp:DataList>

 

 

 

Thanks.....

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...