Hi muhammad12,
Please refer below sample.
HTML
EventId:
<asp:Label ID="lblId" runat="server" />
<br />
Event:
<asp:TextBox ID="txtEvent" runat="server" />
<br />
<asp:Panel ID="Panel1" runat="server" Visible="false">
<div id="outer1">
<div class="inner1">
<asp:TextBox ID="TextBox1" runat="server" />
</div>
</div>
</asp:Panel>
<asp:Panel ID="Panel2" runat="server" Visible="false">
<div id="outer2">
<div class="inner2">
<asp:Button Text="Start Time" runat="server" />
<asp:TextBox ID="txtStart" runat="server" />
</div>
</div>
</asp:Panel>
<asp:Panel ID="Panel3" runat="server" Visible="false">
<div id="outer3">
<div class="inner3">
<asp:Button Text="Start Time" runat="server" OnClick="StartTime" />
<asp:TextBox ID="txtStartTime" runat="server" />
<br />
<asp:Button Text="Stop Time" runat="server" OnClick="StopTime" />
<asp:TextBox ID="txtStopTime" runat="server" />
</div>
</div>
</asp:Panel>
<br />
Department
<asp:TextBox ID="txtDepartment" runat="server" />
Namespace
C#
using System.Data;
VB.Net
Imports System.Data
Code
C#
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
DataTable dt = new DataTable();
dt.Columns.AddRange(new DataColumn[4] {
new DataColumn("EventId",typeof(int)),
new DataColumn("EventName", typeof(string)),
new DataColumn("Property",typeof(string)),
new DataColumn("Dept", typeof(string))});
dt.Rows.Add("01", "A", "3", "CS");
lblId.Text = dt.Rows[0]["EventId"].ToString();
txtEvent.Text = dt.Rows[0]["EventName"].ToString();
txtDepartment.Text = dt.Rows[0]["Dept"].ToString();
string type = dt.Rows[0]["Property"].ToString();
if (type == "1") { Panel1.Visible = true; }
if (type == "2") { Panel2.Visible = true; }
if (type == "3") { Panel3.Visible = true; }
}
}
protected void StartTime(object sender, EventArgs e)
{
txtStartTime.Text = DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss");
}
protected void StopTime(object sender, EventArgs e)
{
txtStopTime.Text = DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss");
}
VB.Net
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
If Not Me.IsPostBack Then
Dim dt As DataTable = New DataTable()
dt.Columns.AddRange(New DataColumn(3) {
New DataColumn("EventId", GetType(Integer)),
New DataColumn("EventName", GetType(String)),
New DataColumn("Property", GetType(String)),
New DataColumn("Dept", GetType(String))})
dt.Rows.Add("01", "A", "3", "CS")
lblId.Text = dt.Rows(0)("EventId").ToString()
txtEvent.Text = dt.Rows(0)("EventName").ToString()
txtDepartment.Text = dt.Rows(0)("Dept").ToString()
Dim type As String = dt.Rows(0)("Property").ToString()
If type = "1" Then
Panel1.Visible = True
End If
If type = "2" Then
Panel2.Visible = True
End If
If type = "3" Then
Panel3.Visible = True
End If
End If
End Sub
Protected Sub StartTime(ByVal sender As Object, ByVal e As EventArgs)
txtStartTime.Text = DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss")
End Sub
Protected Sub StopTime(ByVal sender As Object, ByVal e As EventArgs)
txtStopTime.Text = DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss")
End Sub
Screenshot