Hello mansoorkpy,
Please refer the below codes.
HTML
<asp:Repeater runat="server" ID="Repeater1" OnItemDataBound="Repeater1_ItemDataBound">
<ItemTemplate>
<div style="border-style: ridge; color: black; width: 100%; float: left">
<div style="padding: 5px;">
التاريخ :
<asp:Label ID="lblDate" runat="server" Text='<%#Eval("DTDate")%>' Width="250px" />
اليوم :
<asp:Label ID="lblDay" runat="server" Text='<%#Eval("DTDay")%>' Width="30px" />
وقت العمل :
<asp:Label ID="lbldutytime" runat="server" Text='<%#Eval("DTStartTime","{0}") + "-" + Eval("DTEndTime","{0}")%>' />
<asp:HiddenField ID="HFDTId" runat="server" Value='<%#Eval("DTID")%>' />
<hr />
<asp:GridView ID="GVTaskDeatils" runat="server" AutoGenerateColumns="false" OnRowDataBound="GVTaskDeatils_RowDataBound">
<Columns>
<asp:BoundField DataField="DTDate" HeaderText="DTDate" ReadOnly="true" />
<asp:BoundField DataField="DTDay" HeaderText="DTDay" ReadOnly="true" />
<asp:BoundField DataField="DTStartTime" HeaderText="DTStartTime" ReadOnly="true" />
<asp:BoundField DataField="DTEndTime" HeaderText="DTEndTime" ReadOnly="true" />
</Columns>
</asp:GridView>
<br />
</div>
</div>
<div style="clear: both"></div>
</ItemTemplate>
</asp:Repeater>
Code
C#
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
Repeater1.DataSource = GetData();
Repeater1.DataBind();
}
}
private DataTable GetData()
{
DataTable dt = new DataTable();
dt.Columns.Add("DTID");
dt.Columns.Add("DTDate");
dt.Columns.Add("DTDay");
dt.Columns.Add("DTStartTime");
dt.Columns.Add("DTEndTime");
dt.Rows.Add(1, "16/08/2024", "Friday", "10:30", "03:30");
dt.Rows.Add(2, "17/08/2024", "Saturday", "10:30", "03:30");
dt.Rows.Add(3, "19/08/2024", "Monday", "10:30", "03:30");
return dt;
}
protected void GVTaskDeatils_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.Header)
{
e.Row.Cells[3].Visible = false;
}
}
protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
GridView gvTaskDetails = (GridView)e.Item.FindControl("GVTaskDeatils");
gvTaskDetails.DataSource = GetData();
gvTaskDetails.DataBind();
}
}
VB.NET
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
If Not Me.IsPostBack Then
Repeater1.DataSource = GetData()
Repeater1.DataBind()
End If
End Sub
Private Function GetData() As DataTable
Dim dt As DataTable = New DataTable()
dt.Columns.Add("DTID")
dt.Columns.Add("DTDate")
dt.Columns.Add("DTDay")
dt.Columns.Add("DTStartTime")
dt.Columns.Add("DTEndTime")
dt.Rows.Add(1, "16/08/2024", "Friday", "10:30", "03:30")
dt.Rows.Add(2, "17/08/2024", "Saturday", "10:30", "03:30")
dt.Rows.Add(3, "19/08/2024", "Monday", "10:30", "03:30")
Return dt
End Function
Protected Sub GVTaskDeatils_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs)
If e.Row.RowType = DataControlRowType.Header Then
e.Row.Cells(3).Visible = False
End If
End Sub
Protected Sub Repeater1_ItemDataBound(ByVal sender As Object, ByVal e As RepeaterItemEventArgs)
If e.Item.ItemType = ListItemType.Item OrElse e.Item.ItemType = ListItemType.AlternatingItem Then
Dim gvTaskDetails As GridView = CType(e.Item.FindControl("GVTaskDeatils"), GridView)
gvTaskDetails.DataSource = GetData()
gvTaskDetails.DataBind()
End If
End Sub
Screenshot: