Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET
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.
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 14-Dec-12 21:44pm
Edited 14-Dec-12 21:48pm
v2
Comments
01010RAJ at 15-Dec-12 4:32am
   
Solution 1 is ur answer.

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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..
  Permalink  
v2

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 6,805
1 OriginalGriff 6,696
2 CPallini 5,350
3 George Jonsson 3,609
4 Gihan Liyanage 2,792


Advertise | Privacy | Mobile
Web04 | 2.8.140922.1 | Last Updated 15 Dec 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100