.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
Steve Jackman
Imran Ghani
Santhakumar Munuswamy

Home >> Forum >> C# >> Post New QuestionBookmark and Share Subscribe to Forum

insert and display data in gridview in c#

Posted By: Martin     Posted Date: March 11, 2011    Points:5   Category :C#
i have two table 1st is the Admin(Id(uniqueidentifier),Name(varcahr),Address(varcahr),mobno(int),Date(datetime),condition (varchar),IssueId(uniqueidentifier))

and 2nd childtable(Id(uniqueidentifier),course(varchar))

now i want one application where one textbox for Name,2nd textbox for Date, 3rd dropdownlist for condition ,and 4th dropdownlist or course.


can anyone help me how to write code for insert value by mention control and display in grid using c#.

It would be helpful if you can show me this example with stored procedure.

thanks



Responses
Author: Maverick             
Posted Date: March 12, 2011     Points: 20   

Hello,

You please specify ur requirement more clearly.
Anyways you can use insert statemnt in ur stored proc.

Create sp_insertstudent
(
@name varchar,
@condition varchar,
@date datetime
)
as
Begin
insert into <table> (name,condition,[date]) values @name,@condition,@date)
End

Hope it helps
Thanks,
Maverick

Thanks,
Maverick
Author: Martin             
Posted Date: March 12, 2011     Points: 20   

actually i made two table 1 is Student(Id(int),Name(varchar),Address(varchar),Mob(int)) and 2 nd table is
Course (Id(int),Types(varchar))..

so now i want one form which have one
TextBox1 for Name ,(user insert date at runtime )
TextBox2 for Mob. (user insert Mob at runtime )
Dropdownlist1 for Types........(ddl select Coursetypes like BE,MCA,CA,BCA, at run time)

Button1 for save(insert)

now i want C# code when user insert then all insert and selected option will be insert in databse..

please sortout my problem...as soon as



Author: Martin             
Posted Date: March 12, 2011     Points: 20   

actually i made two table 1 is Student(Id(int),Name(varchar),Address(varchar),Mob(int)) and 2 nd table is
Course (Id(int),Types(varchar))..

so now i want one form which have one
TextBox1 for Name ,(user insert date at runtime )
TextBox2 for Mob. (user insert Mob at runtime )
Dropdownlist1 for Types........(ddl select Coursetypes like BE,MCA,CA,BCA, at run time)

Button1 for save(insert)

now i want C# code when user insert then all insert and selected option will be insert in databse..

please sortout my problem...as soon as



Author: kamlesh             
Posted Date: March 14, 2011     Points: 20   

hi
u write store procedure for save the student information and course

and write code on submit button..

public static List<StudentDetailsDto> GetStudentInformationfromDatabase(string StrQuery)
{
SqlConnection Conn;
List<StudentDetailsDto> studentlist= new List<StudentDetailsDto>();
try
{

Conn = new SqlConnection(Common.ConnectionString);
Conn.Open();
SqlCommand sqlCmd = new SqlCommand(StrQuery, Conn);
sqlCmd.CommandType = CommandType.Text;


SqlDataAdapter da = new SqlDataAdapter(sqlCmd);
DataTable dt = new DataTable();
da.Fill(dt);
for (int i = 0; i < dt.Rows.Count; i++)
{

for

Student Id,Name,Address,Mob

and


Course Id,Types
studentlist.Add(StudentDetailsDto);
}
Conn.Close();
sqlCmd.Dispose();
}
catch (Exception ex)
{
//MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
clsError.LogError(ex);
}

return studentlist;

}



Thanks And Regards.
Kamlesh Nikam


Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend