asp.net一些控件的使用

Lable

<asp:Label ID="Label1" runat="server" Text="Label" CssClass="font_style21"></asp:Label>

后台cs文件对lable赋值

this.Label4.Text = “this is a lable”;

Button

    <asp:Button ID="Button4" runat="server" onclick="Button4_Click"
        Text="check answer" />

TextBox

<asp:TextBox ID="TextBox1" runat="server" Height="126px" TextMode="MultiLine"
        Width="219px"></asp:TextBox>

后台对textbox取值与赋值:

TextBox2.Text = this.TextBox1.Text;
TextBox1.Text = "this is good";//str;

RadioButtonList

西游记中的二师兄是?<br />
    <asp:RadioButtonList ID="RadioButtonList1" runat="server">
        <asp:ListItem>小沙</asp:ListItem>
        <asp:ListItem>小猪</asp:ListItem>
        <asp:ListItem>小白</asp:ListItem>
        <asp:ListItem>小猴</asp:ListItem>
    </asp:RadioButtonList>

得到当前选中项:

string str=RadioButtonList1.SelectedValue.ToString();

DropDownList

<asp:DropDownList ID="DropDownList1" runat="server"
        onselectedindexchanged="DropDownList1_SelectedIndexChanged">
        <asp:ListItem>admin</asp:ListItem>
        <asp:ListItem>supermarket</asp:ListItem>
        <asp:ListItem>bathroom</asp:ListItem>
        <asp:ListItem>carteen</asp:ListItem>
    </asp:DropDownList>

Image

<asp:Image ID="Image1" runat="server" AlternateText="pic can't show"
        Height="131px" Width="156px" />

设置图片地址:

Image1.ImageUrl = "1.gif";

读取数据集DataSet

*.aspx 文件中  <%=strds%>

DataSet ds = new DataSet();

 ds = bll.GetList(strWhere.ToString());

 string strds = "<table border=1> ";
 for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
 {
         strds = strds + "<tr>";
         for (int j = 0; j < 2; j++)
         {
                    strds+="<td class='font_style21'>"+ds.Tables[0].Rows[i][j].ToString()+"</td>";
         }
         strds = strds + "</tr>";
 }
 strds += "</table>";

原文地址:https://www.cnblogs.com/huangzq/p/3119296.html