Click here to Skip to main content
15,891,184 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have created a one form which consits of various fields.
this fields data i have succesfully saved in the database.
Now i have created one more form which consits of one drop down list.
i want drop down list should contain a primary key value,and after selecting a particular value value from dropdown list the whole details of that associated primary key should be display in the gridview.

This is what i have done in the first page.
In the following code stdid is a Primary key of the table.
C#
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;
public partial class FillInformation : System.Web.UI.Page
{
    SqlConnection con;
        
    protected void Page_Load(object sender, EventArgs e)
    {
       

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        SqlConnection con= new SqlConnection("server=SACHIN-5DDBFA03\\SACHIN;uid=sa;password=india;database=master");
        con.Open();
        SqlCommand cmd = new SqlCommand("insert into Students_Details values(@stdid,@sfname,@slname,@Maths,@Science,@SocialScience,@Address)",con);
        cmd.Parameters.Add("@stdid",txtrollnumber.Text);
        cmd.Parameters.Add("@sfname",txtfname.Text);
        cmd.Parameters.Add("@slname",txtlname.Text);
        cmd.Parameters.Add("@Maths", txtmath.Text);
        cmd.Parameters.Add("@Science", txtscience.Text);
        cmd.Parameters.Add("@SocialScience", txtsoscience.Text);
        cmd.Parameters.Add("@Address",txtaddress.Text);

        cmd.ExecuteNonQuery();
        con.Close();

        Response.Write("One Record Inserted Succesfully");
        

    }
    protected void next_Click(object sender, EventArgs e)
    {
        Response.Redirect("Students_Details.aspx");
    }
}

can any 1 give coding for the second page.
Please give me easy solution as much as possible.
Posted
Updated 14-Dec-12 21:48pm
v2
Comments
StackQ 15-Dec-12 4:32am    
Solution 1 is ur answer.

1 solution

No, we won't give you solution.. We can't work out for you like this.. You should try it by yourself.. If you got stuck somewhere, you can certainly come here.. But don't ask directly for code..
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900