Click here to Skip to main content
15,903,854 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
The back end and web designer side code that I asked before was beautifully corrected and written by you, great teacher. Again, on the web designer side, I wanted the values ​​coming from the database to the textbox structures to be listed along the line with the option and checkbox options checked in the loop until the end of the log reading, but I was getting errors, but I could not succeed.


yours code

back end side
C#
using System.Configuration;
using System.Data;
using System.Data.SqlClient;

public partial class Default3 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
    }

    public IEnumerable<idatarecord> ListUrunlers()
    {
        SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["constr"].ToString());
        SqlCommand command = new SqlCommand("SELECT * FROM country", connection);
        connection.Open();
        SqlDataReader dr = command.ExecuteReader();

        while (dr.Read())
        {
            yield return dr;
        }
    }
}


web desıgner side
web form desıgner sıde
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default3.aspx.cs" Inherits="Default3" %> 
<%@ Import Namespace="System.Data" %>

    <title>
        <% foreach (IDataRecord record in ListUrunlers()) { %>
                   
                <% } %>
        <table><tbody><tr>                    <td><%= record["countryid"] %> </td>                    <td><%= record["ulkeismi"] %> </td>                    <td><%= record["photo"] %> </td></tr>            </tbody></table>


-----------------no problems above


Where I stitched the web designer part
    <% foreach (IDataRecord record in ListUrunlers()) { %>

        <% } %>
<table><tbody><tr>                    <td><%= record["countryid"] %> </td>                    <td><%= record["ulkeismi"] %> </td>                    <td><%= record["photo"] %> </td>                  <td>  Label2.Text = "countryid"; textbox1.Text = RECORD["countryid"].ToString() </td>                        <td>   Label3.Text = "ulkeismi"; textbox2.Text = record["ulkeismi"].ToString() </td>                   <td>    Label4.Text = "photo";   textbox3.Text = record["photo"].ToString() </td><td>  optionchose1.checked=true </td><td>  checkboxchose1.checked=true </td></tr>            </tbody></table>


What I have tried:

Where I stitched the web designer part
    <% foreach (IDataRecord record in ListUrunlers()) { %>

        <% } %>
<table><tbody><tr>                    <td><%= record["countryid"] %> </td>                    <td><%= record["ulkeismi"] %> </td>                    <td><%= record["photo"] %> </td>                  <td>  Label2.Text = "countryid"; textbox1.Text = RECORD["countryid"].ToString() </td>                        <td>   Label3.Text = "ulkeismi"; textbox2.Text = record["ulkeismi"].ToString() </td>                   <td>    Label4.Text = "photo";   textbox3.Text = record["photo"].ToString() </td><td>  optionchose1.checked=true </td><td>  checkboxchose1.checked=true </td></tr>            </tbody></table>


I would like to thank you, I could not do this on the web designer side.
Posted
Updated 23-Sep-23 7:40am
v2
Comments
Mike Hankey 23-Sep-23 13:33pm    
Wow you've got some serious formatting issues. I suggest you clean things up!
Dave Kreskowiak 23-Sep-23 13:41pm    
I put in a little work to clean his code up, but I'm not ripping what's left of my hair out to format the rest of his crap. If this is what his code really looks like, it's no wonder he can't figure out the simple things he's doing wrong.
Mike Hankey 23-Sep-23 13:47pm    
You cleaned it up a lot, but it's not your job. The person requesting help should take the effort to clean it up if they want help!
Dave Kreskowiak 23-Sep-23 17:48pm    
True.

Looking at it though, it's amusing every loop does nothing because there's no code inside the curly braces.

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900