softweb001 Posted April 2, 2014 Share Posted April 2, 2014 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 More sharing options...
justsomeguy Posted April 2, 2014 Share Posted April 2, 2014 What do you have so far? Link to comment Share on other sites More sharing options...
softweb001 Posted April 3, 2014 Author Share Posted April 3, 2014 i want to display data on a page and i want it to be inside a div tag Link to comment Share on other sites More sharing options...
justsomeguy Posted April 3, 2014 Share Posted April 3, 2014 You said that in the first post, that doesn't answer my question. Link to comment Share on other sites More sharing options...
softweb001 Posted April 4, 2014 Author Share Posted April 4, 2014 ii have retrieved the data using a datalist but am getting an error about my with the OnCancelCommand attribute Link to comment Share on other sites More sharing options...
thescientist Posted April 4, 2014 Share Posted April 4, 2014 in other words, show your code Link to comment Share on other sites More sharing options...
softweb001 Posted April 9, 2014 Author Share Posted April 9, 2014 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now