| i have a query in asp net. in an application i have textbox and a multiselect listbox. the values which got selected in these two controls i need to pass them to two different parameter so that when they are used in sql query i can get the values of other columns also on the basis of these passed values on grid view on the same page. can anyone tell me how to achieve this in simple steps with eg m just a begginner and working on .net first time. |
Loading
Vaibhav ChaudharyPosted Dec 3, 2010, 7:54 AM
1. Suppose u have a LISTBOX with Name "LstTable" wit Property SelectionMode="MultiExtended".
2. Take Button wit Name BtnCombine
3. Below ListBox take 1 textbox to get value frm listbox after multiple selection
4. Select multiple items from listbox and thn press "BtnCombine" button.
5. Now,attaching code
private void BtnCombine_Click(object sender, EventArgs e)
{
textBox1.Text = null;
for (i = 0; i < (LstTable.Items.Count);i++ )
{
if(i!=0)
textBox1.Text += "-";
textBox1.Text += LstTable.SelectedItems[i].ToString();
}
string str = textBox1.Text;
string[] SelectedItem = str.Split('-');
for (int i = 0; i < SelectedItem.Length; i++)
{
textBox1.Text = SelectedItem[i];
}
}
i think tis can help u to pass query as array is used...
Reply if there is error or not getng...!
Dipa AhujaPosted May 7, 2010, 8:05 AM