1.)我使用下面的代碼將項目從一個RadListBox
轉移到另一個。獲取所有轉移的RadListBox項目標籤並使用RadListBox_items綁定RadGrid,ID
HTML代碼:
A<telerik:RadListBox ID="RadListBox1" runat="server" Width="250px" Height="200px"
TransferMode="Move" AllowTransfer="True" TransferToID="rlbGI_BU" SelectionMode="Multiple"
OnTransferred="RadListBox1_Transferred"
AutoPostBackOnTransfer="true">
</telerik:RadListBox>
B<telerik:RadListBox ID="RadListBox2" runat="server" Width="250px" Height="200px"
EnableEmbeddedSkins="False" Skin="MetroRed" ImagesPath="../App_Themes/MetroRed/ListBox"
OnInserted="RadListBox2_Inserted" SelectionMode="Multiple"
OnDeleted="RadListBox2_Deleted" AutoPostBackOnDelete="true">
</telerik:RadListBox>
<br />
<asp:Label runat="server" ID="lblDeletedList2"></asp:Label>
<asp:Label runat="server" ID="lblInsertedList2"></asp:Label>
<asp:Label runat="server" ID="lblTransdList1"></asp:Label>
C#代碼:
private string _SPID = null;
private DataTable _dtSPBU = null;
protected void Page_Load(object sender, EventArgs e)
{
_SPID = Request.QueryString["SPID"];
if (!string.IsNullOrEmpty(_SPID))
{
_dtSPBU = SDM.SPBU.GetSPBUBySPBUfoSPID(_SPID);
}
}
protected void bind_RadListBox1()
{
RadListBox1.DataTextField = "BUName";
RadListBox1.DataValueField = "SPBUfoBUID";
RadListBox1.DataSource = _dtSPBU;
RadListBox1.DataBind();
}
protected void RadListBox2_Inserted(object sender, RadListBoxEventArgs e)
{
ArrayList myTest = new ArrayList();
//StringBuilder s = new StringBuilder();
for (int i = 0; i < e.Items.Count; i++)
{
myTest.Add(rlbGI_BU.Items[i].Text);
foreach (string x in myTest)
{
lblInsertedList2.Text += x + ", " + " ";
}
}
}
protected void RadListBox2_Deleted(object sender, RadListBoxEventArgs e)
{
lblDeletedList2.Text += e.Items.Count.ToString() + " items are deleted";
}
protected void RadListBox1_Transferred(object sender, RadListBoxTransferredEventArgs e)
{
lblTransdList1.Text += e.Items.Count.ToString() + " items are transferred";
}
我想從RadListBox1
轉移項目到RadListBox2
一個Label
控件內部(比如lblInsertedList2
標籤),因爲後面我必須根據RadListBox2內的項目綁定RadGrid
。
爲此,我創建了RadListBox2_Inserted
事件,其中我試圖在Label中獲取RadListBox2
的項目。
現在,當我將多於1項RadListBox1傳輸到RadListBox2(使用Ctrl按鈕)時,將重複第1個選定項目。
示例: RadListBox1具有「a」,「b」,「c」項。 當我從RadListBox1傳輸所有 「一」, 「B」, 「C」 一起向RadListBox2(使用CTRL鍵)
我看到下面的輸出:aababc
正確的輸出應爲:ABC
請查看以下快照上述問題: 再次,RadListBox1有 「A」, 「b」, 「C」 項目 當我從RadListBox1傳輸項目1 1至RadListBox2
Eample: 當我只轉移一個,我看下面的輸出:a(第一次) 當我只轉b時,我看下面輸出:a,a(第二次) 當我只轉c時,我看到下面輸出:a ,A,A(第三次)
請檢查下面的快照上面的問題:
2)我想RadGrid
使用綁定:
- _SPID =請求。查詢字符串[「SPID」]
- 項目獲得的RadListBox2(僅從RadListBox1所選項目)
現在我只用Request.QueryString["SPID"]
結合RadGrid
,所以我得到的所有與「SPID」
實施例:
SPID RadListBox1_Items 值
一個 TEST1
b TEST2
Ç TEST3
我的要求是:如果想在RadListBox2
只拿到了2項 「A」, 「C」 然後RadGrid
數據應基於RadListBox2項目和「SPID」綁定
SPID RadListBox2_Items 值
一個 TEST1
Ç TEST3
我希望我做了我的要求明確。請讓我知道是否有任何困惑。請回答這兩點。
在此先感謝。
我認爲對於 - 環在插入的情況下,使問題... – Sankar
@SankarRaj:謝謝你的回覆。我在'e.Items.Count'中得到了正確的記錄,所以我應該改變什麼呢? – user3196511