Documentos de Académico
Documentos de Profesional
Documentos de Cultura
select*from tblinfo
select*from tblcountry
select*from tbloccupation
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<table >
<tr>
<td>Name:</td>
<td><asp:TextBox ID ="textname"
runat="server"></asp:TextBox></td>
</tr>
<tr>
<td>Gender:</td>
<td><asp:RadioButtonList ID ="rblgender" runat ="server"
RepeatColumns ="3">
<asp:ListItem Text ="male" Value ="1"></asp:ListItem>
<asp:ListItem Text ="female" Value ="2"></asp:ListItem>
<asp:ListItem Text ="other" Value ="3"></asp:ListItem>
</asp:RadioButtonList> </td>
</tr>
<tr>
<td>Country:</td>
<td><asp:DropDownList ID="ddlcountry"
runat="server"></asp:DropDownList></td>
</tr>
<tr>
<td>Occupation:</td>
<td><asp:DropDownList ID ="ddlpesha" runat="server">
</asp:DropDownList></td>
</tr>
<tr>
<td></td>
<td><asp:Button ID ="btninsert" runat="server" Text="Submit"
OnClick="btninsert_Click" /></td>
</tr>
<tr>
<td></td>
<td><asp:GridView ID ="grdvu" runat="server" text="Display"
></asp:GridView> </td>
</tr>
</table>
</div>
</form>
</body>
</html>
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
csharp code
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;
namespace newdymicdrpdwn
{
public partial class WebForm1 : System.Web.UI.Page
{
Display();
if (!IsPostBack)
{
DisplayCountry();
DisplayOccupation();
}
}
public void Display()
{
con.Open();
SqlCommand cmd = new SqlCommand("select* from tblinfo", con);
SqlDataAdapter sda = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
sda.Fill(dt);
con.Close();
grdvu.DataSource = dt;
grdvu.DataBind();
}
public void DisplayCountry()
{
con.Open();
SqlCommand cmd = new SqlCommand("select* from tblcountry ", con);
SqlDataAdapter sda = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
sda.Fill(dt);
con.Close();
ddlcountry.DataValueField = "id"; // table me jiske paas value
123456 hai uska name yha paas krna hota hai// tblcountry ki id paas kri hai
ddlcountry.DataTextField = "Country_name"; // text me jisme data hai
uska name //check in table
ddlcountry .DataSource = dt;
ddlcountry .DataBind();
ddlcountry.Items.Insert(0, new ListItem("--select--", "0"));
}
public void DisplayOccupation()
{
con.Open();
SqlCommand cmd = new SqlCommand("select* from tbloccupation ", con);
SqlDataAdapter sda = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
sda.Fill(dt);
con.Close();
ddlpesha.DataValueField = "id";
ddlpesha.DataTextField = "Occupation_name";
ddlpesha.DataSource = dt;
ddlpesha.DataBind();
ddlpesha.Items.Insert(0, new ListItem("--select--", "0"));
}
protected void btninsert_Click(object sender, EventArgs e)
{
con.Open();
SqlCommand cmd = new SqlCommand("insert into
tblinfo(name,gender,country, occupation)values('" + textname .Text +"','"+rblgender
.SelectedValue +"','"+ddlcountry .SelectedValue +"','"+ddlpesha .SelectedValue
+"')", con);
cmd.ExecuteNonQuery();
con.Close();
Display();
}
}
}