AspdotnetCodes.com
Search
Articles
Books
Resources
Asp.Net News
Downloads
Free Tech Magazines
Asp.Net Web Hosting
Archives
Softwares
Newsletter
Suggest Us
Link to Us
Feeds Subscription
Articles
Questions & Answers
Tips & Tricks
 inserting Dropdown list selected value into database
Posted by nivedita on  12/20/2007 3:38:09 PM Category: ADO.NET
Add to my favorites
Email to friend

I've 2 tables Carriers(Id(PK),Name,Description) and Contracts(Id(PK),CarrierId,ContractNo,..etc)
In webpage i've a dropdown which is filled with Name in Carriers table and i need to display
Name of the Carrier into Contracts.
How can i insert Name and display in gridview.It's very urgent..
Hope someone could helpout.

Thanks,
Nivedita.

Post Your Reply Post New Question

 Viewer's Reply
Make a join query to display Name in GridView
Answered By Moderator1 on 12/20/2007 9:51:54 PM
Hi,

I think there is no problem for you to insert the CarrierId into Contract table. So you can make a equi-join query and display the necessary fields in the GridView.

Select a.Name,b.* from Carriers a, Contracts b Where a.Id=b.CarrierId.

Hope this answer will help you.
Thanks
 
inserting Dropdown list selected value into database
Answered By Sridhar Pettela on 12/21/2007 5:44:09 AM
hai this help u

Page_load() event
{
if(!page.ispostback)
{
sqlconnection con=new sqlconnection(.....);
SqlDataAdapter sda=new SqlDataAdapter("Select t1.Name from Carriers as t1,Contracts as t2 where t1.id=t2.id",con);
DataSet ds=new dataset();
sda.fill(ds);
dropdownlist1.datasource=ds;
dropdownlist1.databind();
}

}

thank u
 
Post Your Reply If you still have problem, post it again under this reply for better response.

 
Sponsored by
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
Many .NET teams are underperforming, is yours?
The ASP.NET 2.0 Anthology: 101 Essential Tips, Tricks & Hacks - Free 156 Page Preview