ASP.NET - Hashtable အရာ

Hashtable အရာကို ကို/အသုံးပြုခြင်း အရာများ ကို အသုံးပြု၍ ပေါ်ထားပါသည်။

Hashtable ဖွဲ့စည်းပါ

Hashtable အရာကို ကို/အသုံးပြုခြင်း အရာများ ကို အသုံးပြု၍ ပေါ်ထားပါသည်။ အကြိစားအားကစား အကြိစားအားကစား အသုံးပြု၍ အချက်အလက်များ အား ရှာဖွေနိုင်ပါသည်။

Add() စကာတင်ကို အသုံးပြု၍ Hashtable တွင် အရာများ ထပ်ပေါင်းပါ၏。

အောက်ပါ စကာတင်မှာ mycountries အမည်ရှိ Hashtable တစ်ခု ဖွဲ့စည်းပြီး အသုံးပြုသော အရာများကို ထပ်ပေါင်းပါသည်:

<script runat="server">
Sub Page_Load
if Not Page.IsPostBack then
  dim mycountries=New Hashtable
  mycountries.Add("C","China")
  mycountries.Add("S","Sweden")
  mycountries.Add("F","France")
  mycountries.Add("I","Italy")
end if
end sub
</script>

အခြေခံအချက်အလက် အဆက်သွယ်ခြင်း

Hashtable အရာကို အဆိုပါ အပေါ်တွင် အခြေခံအချက်အလက်များ အားကစား အင်္ဂါစကားနှင့် အချက်အလက်များ အားစီစဥ်လုပ်ပေးပါသည်:

  • asp:RadioButtonList
  • asp:CheckBoxList
  • asp:DropDownList
  • asp:Listbox

RadioButtonList အပေါ်သို့ အခြေခံအချက်အလက်များ ဘဲ အခြေခံ .aspx စာရင်းတွင် RadioButtonList အပေါ်ကို ဖွဲ့စည်းပါ၏ (အခြေခံ asp:ListItem အရာများ မပါ)။

<html>
<body>
<form runat="server">
<asp:RadioButtonList id="rb" runat="server" AutoPostBack="True" />
</form>
</body>
</html>

နောက်ပိုင်းတွင် စာရင်းပြုလုပ်သော စကာတင်ကို ထပ်ပေါင်းပါ၏:

<script runat="server">
sub Page_Load
if Not Page.IsPostBack then
  dim mycountries=New Hashtable
  mycountries.Add("C","China")
  mycountries.Add("S","Sweden")
  mycountries.Add("F","France")
  mycountries.Add("I","Italy")
  rb.DataSource=mycountries
  rb.DataValueField="Key"
  rb.DataTextField="Value"
  rb.DataBind()
end if
end sub
</script>
<html>
<body>
<form runat="server">
<asp:RadioButtonList id="rb" runat="server" AutoPostBack="True" />
</form>
</body>
</html>

နောက်ပိုင်းတွင် ကိုယ်စားပြုထားသော သတင်းများကို ထပ်ပေါင်းပါ၏။ အသုံးပြုသူက ရွေးချယ်ထားသော RadioButtonList အပေါ်တွင် အဘယ်အရာကိုမဆို စက်တင်တာကို စတင်လုပ်ဆောင်ပါသည်။ အဘယ်အရာကို စက်တင်တာကို စက်တင်ပြီးနောက် လိုင်းတိုင်တွင် အင်္ဂါစကားလုံးတစ်ခု ပေါ်ထားပါသည်:

<script runat="server">
sub Page_Load
if Not Page.IsPostBack then
  dim mycountries=New Hashtable
  mycountries.Add("C","China")
  mycountries.Add("S","Sweden")
  mycountries.Add("F","France")
  mycountries.Add("I","Italy")
  rb.DataSource=mycountries
  rb.DataValueField="Key"
  rb.DataTextField="Value"
  rb.DataBind()
end if
end sub
sub displayMessage(s as Object,e As EventArgs)
lbl1.text="Your favorite country is: " & rb.SelectedItem.Text
end sub
</script>
<html>
<body>
<form runat="server">
<asp:RadioButtonList id="rb" runat="server"
AutoPostBack="True" onSelectedIndexChanged="displayMessage" />
<p><asp:label id="lbl1" runat="server" /></p>
</form>
</body>
</html>

အမှတ်အသား ပြသပါ

စကားလုံးသင်သုံးသူ က လိပ်ရမ်းတိုက် သို့ ထပ်ပေါင်းလိုက်ခြင်း အား ခွင့်ပြုခြင်း မရှိ၊ လိပ်ရမ်းတိုက် ကို အရွယ်အစား ချဲ့ထားခြင်း လုပ်ဆောင်ရန် လိပ်ရမ်းတိုက် အား အသုံးပြုပါ။