<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Test_Page.aspx.cs" Inherits="Grid_Data.Test_Page" %> <!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> <style type="text/css"> .style1 { width: 113px; } </style> </head> <body> <form id="form1" runat="server"> <div> <table style="width: 61%;"> <tr> <td class="style1"> <asp:Label ID="DeptLabel" runat="server" Text="Employee Name :"></asp:Label> </td> <td> <asp:TextBox ID="nameTextBox1" runat="server"></asp:TextBox> </td> </tr> <tr> <td class="style1" > <asp:Label ID="EMPLabel" runat="server" Text="Emp_ID"></asp:Label> :</td> <td> <asp:TextBox ID="empidTextBox2" runat="server"></asp:TextBox> </td> </tr> <tr> <td class="style1" > <asp:Label ID="DeptmntLabel" runat="server" Text="Department"></asp:Label> :</td> <td> <asp:DropDownList ID="Deptdrop" runat="server"> <asp:ListItem>HR</asp:ListItem> <asp:ListItem>ATM</asp:ListItem> <asp:ListItem>R&D</asp:ListItem> </asp:DropDownList> </td> </tr> <tr> <td class="style1" > <asp:Label ID="DesigLabel" runat="server" Text="Designation :"></asp:Label> </td> <td> <asp:DropDownList ID="Desigdrop" runat="server"> <asp:ListItem>AVP</asp:ListItem> <asp:ListItem>CTO</asp:ListItem> <asp:ListItem>DCTO</asp:ListItem> <asp:ListItem>First Executive Officer</asp:ListItem> </asp:DropDownList> </td> </tr> </table> <asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" /> <br /> <asp:Label ID="dept" runat="server" Text="[dept]"></asp:Label> <asp:Label ID="desLabel" runat="server" Text="[des]"></asp:Label> <br /> <div> <asp:GridView ID="showinfogrid" runat="server" AutoGenerateColumns="False" Width="100%"> <Columns> <asp:BoundField DataField ="Name" HeaderText ="Employee_Name" ReadOnly="true" /> <asp:BoundField DataField ="Employee_ID" HeaderText ="Emp_ID" ReadOnly="true"/> <asp:BoundField DataField ="Department" HeaderText ="Department" ReadOnly="true"/> <asp:BoundField DataField ="Designation" HeaderText ="Designation" ReadOnly="true"/> </Columns> </asp:GridView> </div> </div> </form> </body> </html>
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data; namespace Grid_Data { public partial class Test_Page : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { dept.Text=Deptdrop.SelectedItem.Text; desLabel.Text = Desigdrop.SelectedItem.Text; DataTable dt = new DataTable(); this.showinfogrid.Visible = true; dt.Columns.Add("Name"); dt.Columns.Add("Employee_ID"); dt.Columns.Add("Department"); dt.Columns.Add("Designation"); dt.Rows.Add(nameTextBox1.Text.Trim(), empidTextBox2.Text.Trim(), Deptdrop.SelectedItem.Text, Desigdrop.SelectedItem.Text); showinfogrid.DataSource = dt; showinfogrid.DataBind(); } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)