How to Display Data in a GridView Without Using Code
Every organization is always hunting for quality resources for project development. So for every interview round there is always a technical round to check for technical knowledge. Sometimes the logical question is asked. One of my friends asked one question. So I thought to write articles and share with all of you.
Without writing one line of code do the following.
Bind a student_ id to dropdown list. Display the details of the student in a GridView depending on the student _id of the dropdownlist in ASP.Net.
Note: the problem statement was very complicated but I simplified it.
So many times programmers are confused about how to develop without one line of code. Some are saying it is impossible to do without writing one line of code. Some only know how to bind data to a control using data sources. But they don’t know how to check depending on a condition.
It is possible in ASP.NET.
Let’s learn step-by-step.
Open Visual Studio. Click on File -> New -> Website.
Select the language as Visual C# and template as ASP.NET web Forms site. Provide an appropriate name and location and click on OK.
Drag and drop a Dropdownlist onto the page. Check that the Autopostback is enabled. For binding the data source select choose a data source.
Select ”New DataSource” form the first dropdownlist.
Choose the data source that you want to bind to. I chose SQL data source. Click on OK.
If you have already bound to the database, choose something in the dropdownlist otherwise click on New Connection. I chose New Connection.
Enter the server name and choose authentication. If using Server Authentication then enter a User Name and Password. Also select database. And for confirmation of the Test connection, click on Test Connection. If the connection is accessed it displays a message, click on OK. Again, click on OK to close the windows.
Now it displays the connection string. Click on Next.
Check the connection string and save it in the configuration file. And click on Next.
Here in the dropdownlist we are only bound to a Student_id so check the student_id and click on Next.
Click on Test Query to display the available student _id in the database. Click on Finish.
Finally, it displays all the details that you bound to the dropdownllist. Click on OK.
Now the student_id is bound to the dropdownlist.
Next we need to display records depending on the dropdownlist value in the GridView.
Drag and drop one GridView. Select “New data Souce”.
Select SQL Datsource Type and click on OK.
Now directly choose the connection string then click on Next.
Click on Next.
Check * to display all the records. Now we need to display records depending on the condition. Click on where.
Select the student_id column, the operator is = and now here is the main thing. Here we can bind the source. You can bind the source on that in various ways. Here we will bind the control. Choose the control ID as dropdownlist. Click on Add and then the OK button.
Now click on Test Query. You will be rompted for the Parameter, for example I enter the Student id parameter as 1 and click OK.
Now the record is displayed depending on the parameter that was passed. Now click on Finish and run the webpage and check. It displays the details of the student depending on the student id of the dropdownlist.
Best Recommended ASP.NET Hosting
ASPHostPortal.com is Perfect, suitable hosting plan for a starter in ASP.NET Hosting. ASPHostPortal the leading provider of Windows hosting and affordable ASP.NET Hosting. ASPHostPortal proudly working to help grow the backbone of the Internet, the millions of individuals, families, micro-businesses, small business, and fledgling online businesses. ASPHostPortal has ability to support the latest Microsoft and ASP.NET technology, such as: WebMatrix, WebDeploy, Visual Studio 2015, .NET 5/ASP.NET 4.5.2, ASP.NET MVC 6.0/5.2, Silverlight 6 and Visual Studio Lightswitch, ASPHostPortal guarantees the highest quality product, top security, and unshakeable reliability, carefully chose high-quality servers, networking, and infrastructure equipment to ensure the utmost reliability.
HostForLIFE.eu guarantees 99.9% uptime for their professional ASP.NET hosting and actually implements the guarantee in practice. HostForLIFE.eu is the service are excellent and the features of the web hosting plan are even greater than many hosting. HostForLIFE.eu offer IT professionals more advanced features and the latest technology. Relibility, Stability and Performance of servers remain and TOP priority. Even basic service plans are equipped with standard service level agreements for 99.99% uptime. Advanced options raise the bar to 99.99%. HostForLIFE.eu revolutionized hosting with Plesk Control Panel, a Web-based interface that provides customers with 24×7 access to their server and site configuration tools.
DiscountService.biz is The Best and Cheap ASP.NET Hosting. DiscountService.biz was established to cater to an under served market in the hosting industry web hosting for customers who want excellent service. DiscountService.biz guarantees the highest quality product, top security, and unshakeable reliability, carefully chose high-quality servers, networking, and infrastructure equipment to ensure the utmost reliability. DiscountService.biz has ability to support the latest Microsoft and ASP.NET technology, such as: WebMatrix, WebDeploy, Visual Studio 2015, .NET 5/ASP.NET 4.5.2, ASP.NET MVC 6.0/5.2, Silverlight 6 and Visual Studio Lightswitch. DiscountService.biz is devoted to offering the best Windows hosting solution for you.