Dear teacher, first of all, I pray for your health. In your previous project, I managed to direct you to the countrydetails.aspx page with A href and record from there.
I did this successfully in the web designer section, but our teacher wanted us to do the same event on the same page with the button1 click event, so I stitched the code myself, but it did not work, and the sentences did not work. Please forgive my nonsense since it is wrong and it will be a postback event.
In short, the code requires stitching. I put a button1 control, I thought it would get the idno number on each line. I wrote an event for button1. I think what you have done is actually the ancestors of MVC. With my endless respect, I have come somewhere thanks to you. It will be great if we can realize the button1 event for idno on the same page.
There is a one-to-many relationship between the other log, the countrydetail table, and the country table. I wanted it to appear here in other cities of India, sir.
I am causing you a lot of headache, but those who understand these things here do not care about us, sir.
<body>
<form id="form1" runat="server">
<div>
<table style="width: 1000px">
<% foreach (var c in this.item())
{ %>
<tr>
<td class="style3">
<label><%=c.countryid%></label></td>
<td class="style3">
<input type="text" value='<%=c.countryname %>' /></td>
<td class="style3">
<input type="text" value='<%=c.photo%>' /></td>
<td class="style3">
<input type="radio" <%=c.countryname== "india" ? "checked" : "" %> /></td>
<td class="style3">
<input type="checkbox" <%=c.countryname!= "india" ? "checked" : "" %> /></td>
<td class="style4">
<a href='countrydetail.aspx?idno=<%=c.countryid %>'>country detaıl</a> </td>
<td>
<asp:Button ID="Button1" runat="server" Text="Button"
BackColor="#FF6699" Width="500px" OnClick="ON" />
</tr>
<% } %>
</table>
</div>
country detail specific area with button1 click not ahref ı used button1
<div>
<table>
<tr>
<td>
<label><%=detailvar0%></label>
</td>
</tr>
<tr>
<td> <input type="text" value='<%=detailvar1%>' /> <input type="text" <%=detailvar1%>' /></td>
</tr>
<tr>
<td>
<input type="text" value='<%=detailvar2%>' />
</td>
</tr>
<tr>
<td>
<input type="text" value='<%=detailvar3%>' />
</td>
</tr>
<tr>
<td>
<label><%=detailvar3%></label>
</td>
</tr>
</table>
</div>
</form>
</body>
public partial class Default6 : System.Web.UI.Page
{
public string detailvar1;
public string detailvar2;
public string detailvar3;
public string detailvar0;
public List<Country> item()
{
string sqlStatment = "select * from Country";
string constr = System.Configuration.ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
using (System.Data.SqlClient.SqlConnection con = new System.Data.SqlClient.SqlConnection(constr))
{
using (System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand(sqlStatment, con))
{
cmd.Connection.Open();
System.Data.SqlClient.SqlDataReader reader = cmd.ExecuteReader();
List<Country> emp = new List<Country>();
while (reader.Read())
{
Country country = new Country();
country.countryid = Convert.ToInt32(reader.GetValue(0));
country.countryname = reader.GetValue(2).ToString();
country.photo = reader.GetValue(1).ToString();
emp.Add(country);
}
reader.Close();
cmd.Connection.Close();
return emp;
}
}
}
public class Country
{
public int countryid { get; set; }
public string countryname { get; set; }
public string photo { get; set; }
}
public List<Country> Item { get; set; }
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
if (!this.IsPostBack)
{
this.Item = this.item();
}
}
}
protected void ON(object sender, EventArgs e)
{
detailvar0 = countrydetail.aspx ? idno =<%= c.countryid %>; Or under line ı dont make it
detailvar0 = Response.Write(countrydetail.aspx ? idno =<%= c.countryid %>);
string sqlStatment = "select * from Countrydetail WHERE dcountryidno='" + detailvar0 + "'"); ;
string constr = System.Configuration.ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
using (System.Data.SqlClient.SqlConnection con = new System.Data.SqlClient.SqlConnection(constr))
{
using (System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand(sqlStatment, con))
{
cmd.Connection.Open();
System.Data.SqlClient.SqlDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
detailvar0 = Convert.ToInt32(reader.GetValue(0));
detailvar1 = reader.GetValue(1).ToString();
detailvar2 = reader.GetValue(2).ToString();
detailvar3 = reader.GetValue(3).ToString();
}
reader.Close();
cmd.Connection.Close();
}
}
}
}