我在editinfo页面上工作,我做了一个mysql命令,将您登录到站点的帐户的数据插入到文本框中。
所有文本框都是asp.net,例如:asp:listitem
但现在我使用的是输入日期,我真的不知道如何插入它。
<tr>
<td class = "textstyle">
שם פרטי:
</td>
<td class="style3">
<asp:TextBox name = "fname" ID="firstname" runat="server" placeholder = "השם הפרטי שלך"></asp:TextBox>
</td>
</tr>
<tr>
<td class = "textstyle">
שם משפחה:</td>
<td class="style3">
<asp:TextBox name = "lname" ID="lastname" runat="server" placeholder = "שם המשפחה שלך"></asp:TextBox>
</td>
</tr>
<td class = "textstyle">
אזור מגורים:
</td>
<td class="style3">
<asp:DropDownList ID="PlaceList" runat="server">
<asp:ListItem disable hidden>בחר אזור</asp:ListItem>
<asp:ListItem id = "OurPlace">המרכז</asp:ListItem>
<asp:ListItem id = "OurPlace2">השרון</asp:ListItem>
<asp:ListItem id = "OurPlace3">הצפון</asp:ListItem>
<asp:ListItem id = "OurPlace4">הדרום</asp:ListItem>
<asp:ListItem id = "OurPlace5">ירושלים והסביבה</asp:ListItem>
</asp:DropDownList>
<tr>
<td class = "textstyle">
תאריך לידה:</td>
<td class="style3">
<input id="date" name = "date" type="Date" min="1905-01-01" max="2019-01-01" value="2018-01-01"/>
</td>
</tr>
<tr>
<td class = "textstyle"">
מין:</td>
<td class="style3">
<input type = "radio" name="gender" id = "gender1" value ="זכר" /> <div class = "textstyle">זכר</div>
<input type = "radio" name="gender" id = "gender2" value ="נקבה" /> <div class = "textstyle">נקבה</div>
<input type = "radio" name="gender" id = "gender3" value ="אחר" /> <div class = "textstyle">אחר</div>
</td>
</tr>
<tr>
<td class = "textstyle">
אימייל:</td>
<td class="style6">
<asp:TextBox name="email1" ID="MyEmail" runat="server" placeholder = "כתובת האימייל שלך"></asp:TextBox>
<tr><asp:Label ID="IsEmail" runat="server" Font-Names="arial" ForeColor="Red" Width="70px" Font-Size="Medium"></asp:Label></tr>
</td>
</tr>
<tr>
<td class = "textstyle">
סיסמה:</td>
<td class="style3">
<asp:TextBox type = "password" name = "password" id="pass" runat="server" placeholder = "הסיסמה שלך"></asp:TextBox>
</td>
</tr>
<tr>
<td class = "textstyle">
אימות סיסמה:</td>
<td class="style3">
<asp:TextBox type = "password" name = "passwordchecker" ID="passchecker" runat="server" placeholder = "חזור שנית"></asp:TextBox>
</td>
</tr>
editinfo.aspx.cs
protected void Page_Load(object sender, EventArgs e)
{
if (Session["User"] == null)
{
Response.Redirect("Home.aspx");
}
if ((Session["AdminMode"] == "1") || (Session["AdminMode"] == "2"))
UserName = Session["AdminEditUser"].ToString();
else
UserName = Session["User"].ToString();
if (!IsPostBack)
{
string connectionStr = @"Provider=Microsoft.Jet.OleDb.4.0;Data Source=|DataDirectory|\DataBase.mdb";
OleDbConnection connectObj = new OleDbConnection(connectionStr);
string mySql = "SELECT * from Users WHERE userName= '" + UserName + "'";
OleDbDataAdapter dataAdapt = new OleDbDataAdapter(mySql, connectObj);
DataSet ds = new DataSet();
dataAdapt.Fill(ds, "users");
DataRow row = ds.Tables["users"].Rows[0];
pass.Text = row[1].ToString();
passchecker.Text = row[1].ToString();
firstname.Text = row[2].ToString();
lastname.Text = row[3].ToString();
MyEmail.Text = row[4].ToString();
PlaceList.Text = row[5].ToString();
}
}
问题图片-单击此处
1条答案
按热度按时间tez616oj1#
其他html控件id在代码隐藏中找到,只需在html代码中添加runat=“server”。
添加保存值的屏幕快照:
.aspx页面在日期文本框中添加绑定值的屏幕快照:
.cs页代码
日期文本框填充值的屏幕截图。
在编辑模式下,我们使用java脚本设置date的值