Hi ronaldlour,
Please refer below sample.
Note: For this sample i have used temporary DataTable. For more details refer How to create Temporary Table in ASP.Net using C# and VB.Net. How to create Temporary Table in ASP.Net using C# and VB.Net
HTML
<asp:DataList ID="dlSchedule" runat="server" RepeatColumns="4" CellPadding="4" >
<ItemTemplate>
<table class="">
<tr class="inputtr">
<td>
<div>
<div id="Div43" runat="server">
<asp:Button CssClass="btn" ID="btnSchedule" runat="server" Text="Schedule" CommandArgument="Schedule" OnClick="Schedule" />
</div>
</div>
<div>
<div id="Div44" runat="server">
<asp:Button CssClass="btn" ID="btnReSchedule" runat="server" Text="ReSchedule" CommandArgument="Reschedule" OnClick="Schedule" OnClientClick="return confirm('Are you sure you want to ReSchedule? This will delete previous Schedule.');" />
</div>
</div>
</td>
<td>
<div>
<div>
<asp:TextBox ID="txtDateTime" runat="server" placeholder="dd/mm/yyyy" TextMode="DateTimeLocal" ReadOnly="false"></asp:TextBox>
</div>
</div>
<div>
<div id="Div42" runat="server">
<asp:TextBox ID="txtSchedule" runat="server" Enabled="false" ReadOnly="false" value='<%# Eval("Schedule")%>'></asp:TextBox>
</div>
</div>
</td>
</tr>
</table>
</ItemTemplate>
</asp:DataList>
Namespace
C#
using System.Data;
VB.Net
Imports System.Data
Code
C#
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
this.BindDataList();
}
}
protected void Schedule(object sender, EventArgs e)
{
Button btnSelect = sender as Button;
string commandArgs = btnSelect.CommandArgument;
if (commandArgs.ToLower() == "schedule")
{
TextBox txtDateTime = btnSelect.Parent.Parent.FindControl("txtDateTime") as TextBox;
ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('" + txtDateTime.Text.Replace("T", " ") + "');", true);
}
else if (commandArgs.ToLower() == "reschedule")
{
}
}
private void BindDataList()
{
DataTable dt = new DataTable();
dt.Columns.Add(new DataColumn("Schedule"));
dt.Rows.Add("03/06/2022");
dlSchedule.DataSource = dt;
dlSchedule.DataBind();
}
VB.Net
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
If Not Me.IsPostBack Then
Me.BindDataList()
End If
End Sub
Protected Sub Schedule(ByVal sender As Object, ByVal e As EventArgs)
Dim btnSelect As Button = TryCast(sender, Button)
Dim commandArgs As String = btnSelect.CommandArgument
If commandArgs.ToLower() = "schedule" Then
Dim txtDateTime As TextBox = TryCast(btnSelect.Parent.Parent.FindControl("txtDateTime"), TextBox)
ClientScript.RegisterStartupScript(Me.[GetType](), "alert", "alert('" & txtDateTime.Text.Replace("T", " ") & "');", True)
ElseIf commandArgs.ToLower() = "reschedule" Then
End If
End Sub
Private Sub BindDataList()
Dim dt As DataTable = New DataTable()
dt.Columns.Add(New DataColumn("Schedule"))
dt.Rows.Add("03/06/2022")
dlSchedule.DataSource = dt
dlSchedule.DataBind()
End Sub
Screenshot