AbstractEvery 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.Problem statementWithout 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.SolutionSo 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.Step 1Open Visual Studio. Click on File -> New -> Website. Step 2Select the language as Visual C# and template as ASP.NET web Forms site. Provide an appropriate name and location and click on OK.Step 3Drag and drop a Dropdownlist onto the page. Check that the Autopostback is enabled. For binding the data source select choose a data source. Step 4Select ”New DataSource” form the first dropdownlist.Step 5Choose the data source that you want to bind to. I chose SQL data source. Click on OK.Step 6If you have already bound to the database, choose something in the dropdownlist otherwise click on New Connection. I chose New Connection.Step 7Enter 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.Step 8Now it displays the connection string. Click on Next.Step 9Check the connection string and save it in the configuration file. And click on Next.Step 10Here in the dropdownlist we are only bound to a Student_id so check the student_id and click on Next. Step 11Click on Test Query to display the available student _id in the database. Click on Finish.Step 12Finally, 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.Step 13Drag and drop one GridView. Select “New data Souce”.Step 14Select SQL Datsource Type and click on OK. Step 15Now directly choose the connection string then click on Next.Step 16Click on Next.Step 17Check * to display all the records. Now we need to display records depending on the condition. Click on where.Step 18Select 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.Step 19Now click on Test Query. You will be rompted for the Parameter, for example I enter the Student id parameter as 1 and click OK.Step 20Now the record is displayed depending on the parameter that was passed. Now click on Finish.Step 21Now run the webpage and check. It displays the details of the student depending on the student id of the dropdownlist.I hope you like my article.If you have any such kind of problem statement then frankly drop mail to me at [email protected]. I am happy to help you and provide a better solution.For more article visit my blog.Your feedback and suggestion is always welcomed by me.
You need to be a premium member to use this feature. To access it, you'll have to upgrade your membership.
Become a sharper developer and jumpstart your career.
$0
$
. 00
monthly
For Basic members:
$20
For Premium members:
$45
For Elite members: