Regarding C# RRS feed

  • Question

  • User-1162083151 posted

    Dear Sir,

    I want to start coding in C# thats y I try to create new form in C# Coding,can anyone give me one example or task to create new form.



    Saturday, October 5, 2019 10:31 AM


  • User665608656 posted

    Hi nsawant,

    According to your description, What 'form' do you refer to, winform or webform?

    If it is webform , I created a simple to add data to the database, you can follow these codes:

    <!DOCTYPE html>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <form id="form1" runat="server">
                <table class="auto-style1">
                        <td>Name :</td>
                            <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
                        <td>Subject :</td>
                            <asp:DropDownList ID="DropDownList1" runat="server">
                                <asp:ListItem Text="English" Value="English" Selected="True"></asp:ListItem>
                                <asp:ListItem Text="Maths" Value="Maths"></asp:ListItem>
                                <asp:ListItem Text="PE" Value="PE"></asp:ListItem>
                                <asp:ListItem Text="Music" Value="Music"></asp:ListItem>
                        <td>Score :</td>
                            <asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
                            <asp:Button ID="Button1" runat="server" Text="Submit" OnClick="Button1_Click" />
     protected void Button1_Click(object sender, EventArgs e)
                SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
                string sql = "INSERT INTO Students (SName,Subject,Score) VALUES (@SName,@Subject,@Score)";
                SqlCommand cmd = new SqlCommand(sql, con);
                cmd.Parameters.AddWithValue("@SName", TextBox1.Text.ToString());
                cmd.Parameters.AddWithValue("@Subject", DropDownList1.SelectedValue.ToString());
                cmd.Parameters.AddWithValue("@Score", Convert.ToInt32(TextBox3.Text.ToString()));
                cmd.CommandType = CommandType.Text;

    For more details, you could refer to this link : Creating A Simple Registration Form In ASP.NET

    Best Regards,


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, October 7, 2019 8:32 AM