0

I want to display my database table's one row content like as below frame. Table have Photo and description column. I also want two buttons like mentioned in image for some action. my database table have around 100 plus records. so in my web page I want to display 100 frame like below at runtime because it's possible that in future this record may goes up to 1000.

enter image description here

I am new in Web Application development. Anyone suggest me best GUI control to achive my goal with ASP.NET. Any tutorial or sample link will be great help.

Thanks.

2 Answers 2

1

First you create a user control with that design as I see here.

Then you use this user control inside a repeater and pass the database parameters to the user control to make the correct render. Additional you can use and DataView the same way.

working example

The custom control:

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="ShowData.ascx.cs" Inherits="Dokimes_StackOverFlow_ShowData" %>

<asp:Literal runat="server" ID="txtTheID" EnableViewState="false" />

<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />

<hr /><br />

and the code behind:

public partial class Dokimes_StackOverFlow_ShowData : System.Web.UI.UserControl
{
    public int cValueID = -1;

    protected void Page_Load(object sender, EventArgs e)
    {
        txtTheID.Text = cValueID.ToString();
    }

    protected void Button1_Click(object sender, EventArgs e)
    {

    }
}

and the main page that is use it:

<!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">
    <div>    
        <asp:Repeater ID="Repeater1" runat="server">
            <ItemTemplate>
                <uc1:ShowData ID="ShowData1" runat="server" cValueID="<%# GetID(Container.DataItem) %>" />          
            </ItemTemplate>
        </asp:Repeater>    
    </div>    
    </form>
</body>
</html>

and the code behind

public partial class Dokimes_StackOverFlow_ShowRepeatedData : System.Web.UI.Page
{
    List<int> oMainIds = new List<int>();

    override protected void OnInit(EventArgs e)
    {
        for (int i = 0; i < 10; i++)
        {
            oMainIds.Add(i);
        }

        Repeater1.DataSource = oMainIds;
        Repeater1.DataBind();

        base.OnInit(e);
    }

    protected void Page_Load(object sender, EventArgs e)
    {
    }

    public int GetID(object oItem)
    {
        return (int)oItem;
    }
}
Sign up to request clarification or add additional context in comments.

Comments

1

You can use listview control because it supports custom formatting. repeater is the second option but listview has more features than repeater.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.