使用两个列表框为多种印度语言和国家选择使用数据库.. [英] use two listbox for multiple indian languages and countries select using database..

查看:68
本文介绍了使用两个列表框为多种印度语言和国家选择使用数据库..的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

==>如何从数据库绑定列表框项目...



==> 2个不同语言的列表框..(像matromony ......和工作相关的网站有...)



==>第一个列表框从数据库绑定(语言表)< br $> b $ b

==>第二个列表框是空白的



==>从第一个列表框中选择多种语言并存储到第二个列表框中



==>在第二个列表框中选择哪些语言...从第一个列表框中删除这些语言





==>我知道两个列表框的简单编码,如add,add_all,move,move_all

但不知道如何访问数据库...如何存储在数据库中并从数据库绑定...

和从数据库绑定时......那个时候哪些语言在第二个列表框中....他们将不会在firstlistbox中...

.m对不起我的危险解释你..

给我简单的编码..

==>how to bind listbox items from database...

==> 2 listbox for different languages.. (like matromony..and job related websites have..)

==>first listbox bind from database (languages table)

==> second listbox is blank

==>select multiple languages from first listbox and store into second listbox

==> which languages are selected in second listbox...those languages are removed from first listbox
.

==> i know the simple coding of two listbox like add, add_all, move, move_all
but dont know how to access with database...how to store in database and bind from database...
and when bind from database...that time which languages are in second listbox....they will not have in firstlistbox...
.m sorry for my dangerous explainantion to you..
give me simple coding..

推荐答案

填写列表框



DataTable UserInfo = con.GetData(选择不同的UserName,来自用户名的tbl_UserDetails的UserID);

if(UserInfo.Rows.Count> 0)

{

lstAvaliableUserPool.DataSource = UserInfo;

lstAvaliableUserPool.DataTextField =UserName;

//lstAvaliableUserPool.DataValueField =UserID ;

lstAvaliableUserPool.DataBind();

}







protected void btnSelectUser_Click(object sender,EventArgs e)

{



if(lstAvaliableUserPool.SelectedIndex!= -1)

{

lstSelectedUserPool.Items.Add(lstAvaliableUserPool。 SelectedItem.Text);

lstAvaliableUserPool.Items.RemoveAt(lstAvaliableUserPool.SelectedIndex);

}

}



protected void btnDeSelectUser_Click(object sender,EventArgs e)

{



if(lstSelectedUserPool.SelectedValue!= )

{

lstAvaliableUserPool.Items.Add(lstSelectedUserPool.SelectedValue);

lstSelectedUserPool.Items.RemoveAt(lstSelectedUserPool.SelectedIndex);

}

}



protected void btnSelectAllUsers_Click(object sender,E ventArgs e)

{



for(int i = 0;我< lstAvaliableUserPool.Items.Count; i ++)

{

lstSelectedUserPool.Items.Add(lstAvaliableUserPool.Items [i] .Text);

}

lstAvaliableUserPool.Items.Clear();

}



protected void btndeSelectAllUsers_Click(object sender,EventArgs e)

{



for(int i = 0; i< lstSelectedUserPool.Items.Count; i ++)

{

lstAvaliableUserPool.Items.Add(lstSelectedUserPool.Items [i] .Text);

}

lstSelectedUserPool.Items.Clear();

}
Fill the List Box

DataTable UserInfo = con.GetData("select distinct UserName,UserID from tbl_UserDetails order by UserName");
if (UserInfo.Rows.Count > 0)
{
lstAvaliableUserPool.DataSource = UserInfo;
lstAvaliableUserPool.DataTextField = "UserName";
//lstAvaliableUserPool.DataValueField = "UserID";
lstAvaliableUserPool.DataBind();
}



protected void btnSelectUser_Click(object sender, EventArgs e)
{

if (lstAvaliableUserPool.SelectedIndex != -1)
{
lstSelectedUserPool.Items.Add(lstAvaliableUserPool.SelectedItem.Text);
lstAvaliableUserPool.Items.RemoveAt(lstAvaliableUserPool.SelectedIndex);
}
}

protected void btnDeSelectUser_Click(object sender, EventArgs e)
{

if (lstSelectedUserPool.SelectedValue != "")
{
lstAvaliableUserPool.Items.Add(lstSelectedUserPool.SelectedValue);
lstSelectedUserPool.Items.RemoveAt(lstSelectedUserPool.SelectedIndex);
}
}

protected void btnSelectAllUsers_Click(object sender, EventArgs e)
{

for (int i = 0; i < lstAvaliableUserPool.Items.Count; i++)
{
lstSelectedUserPool.Items.Add(lstAvaliableUserPool.Items[i].Text);
}
lstAvaliableUserPool.Items.Clear();
}

protected void btndeSelectAllUsers_Click(object sender, EventArgs e)
{

for (int i = 0; i < lstSelectedUserPool.Items.Count; i++)
{
lstAvaliableUserPool.Items.Add(lstSelectedUserPool.Items[i].Text);
}
lstSelectedUserPool.Items.Clear();
}


< table>

< tr>

< td>

& nbsp;

< / td>

< td>

< asp:ListBox ID =lstAvaliableUserPoolrunat = serverFont-Names =Arial

Height =150pxWidth =170px>< / asp:ListBox>

< / td>

< td align =centervalign =middle>

< center>

< table>

< tr>

< td align =centervalign =middlewidth =35>

< asp:Button ID =btnSelectUserrunat =serverFont-Bold =TrueFont-Names =Arial

字体大小=8pt高度=20pxOnClick =btnSelectUser_ClickText =& gt;宽度=30px/>

< / td>

< / tr>

< tr>

< td align =centervalign =middlewidth =35>

< asp:Button ID =btnDeSelectUserrunat =serverFont-Bold =True字体名称=Arial

字体大小=8pt高度=20pxOnClick =btnDeSelectUser_ClickText =& lt;宽度=30px/>

< / td>

< / tr>

< tr>

< td align =centervalign =middlewidth =35>

< asp:Button ID =btnSelectAllUsersrunat =serverFont-Bold =True字体名称=Arial

字体大小=8pt高度=20pxOnClick =btnSelectAllUsers_ClickText =& gt;& gt;

宽度=30px/>

< / td>

< / tr>

< tr>

< td align =centervalign =middlewidth =35>

< asp:Button ID =btndeSelectAllUsers runat =serverFont-Bold =True字体名称=Arial

Font-Size =8ptHeight =20pxOnClick =btndeSelectAllUsers_ClickText =& lt;& lt;

Width =30px/>

< / td>

< / tr>

< / table>

< / center>

< / td>

< td>

< asp:ListBox ID =lstSelectedUserPoolrunat =serverFont-Names =Arial

Height =150pxWidth = 170px>< / asp:ListBox>

< / td>

< / tr>

< / table>
<table >
<tr>
<td>
&nbsp;
</td>
<td>
<asp:ListBox ID="lstAvaliableUserPool" runat="server" Font-Names="Arial"
Height="150px" Width="170px"></asp:ListBox>
</td>
<td align="center" valign="middle">
<center>
<table>
<tr>
<td align="center" valign="middle" width="35">
<asp:Button ID="btnSelectUser" runat="server" Font-Bold="True" Font-Names="Arial"
Font-Size="8pt" Height="20px" OnClick="btnSelectUser_Click" Text="&gt;" Width="30px" />
</td>
</tr>
<tr>
<td align="center" valign="middle" width="35">
<asp:Button ID="btnDeSelectUser" runat="server" Font-Bold="True" Font-Names="Arial"
Font-Size="8pt" Height="20px" OnClick="btnDeSelectUser_Click" Text="&lt;" Width="30px" />
</td>
</tr>
<tr>
<td align="center" valign="middle" width="35">
<asp:Button ID="btnSelectAllUsers" runat="server" Font-Bold="True" Font-Names="Arial"
Font-Size="8pt" Height="20px" OnClick="btnSelectAllUsers_Click" Text="&gt;&gt;"
Width="30px" />
</td>
</tr>
<tr>
<td align="center" valign="middle" width="35">
<asp:Button ID="btndeSelectAllUsers" runat="server" Font-Bold="True" Font-Names="Arial"
Font-Size="8pt" Height="20px" OnClick="btndeSelectAllUsers_Click" Text="&lt;&lt;"
Width="30px" />
</td>
</tr>
</table>
</center>
</td>
<td>
<asp:ListBox ID="lstSelectedUserPool" runat="server" Font-Names="Arial"
Height="150px" Width="170px"></asp:ListBox>
</td>
</tr>
</table>


取一个数据表,其中包含第一个列表框的字段。



再添加一列用于保存列表框1的标志&list box 2 items



绑定第一个列表框。



从第一个列表框中选择记录后, upda te数据表标志值根据列表框2的项目(从第一个列表框中选择)



在绑定列表框2之前,尝试根据第一个排序数据表值&第二个列表框然后绑定它。
Take one data table which contains fields for first list box.

Add one more column for holding flag for list box 1 & list box 2 items

Bind first list box.

After selecting records from first list box,update data table flag values according to items for list box 2 (Selected from first list box)

Before bind list box 2, try to sort data table values according to first & second list box & then bind it.


这篇关于使用两个列表框为多种印度语言和国家选择使用数据库..的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆