Drop Down List Firing Code

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hi,
I have this Drop Down List:
<asp:DropDownList ID="DropDownList1" runat="server" Height="22px" Width="76px" <br/>

AutoPostBack="true" <br/>
onselectedindexchanged="DropDownList1_SelectedIndexChanged1 <br/>
<asp:ListItem Text ="jf12" Value="jf12" /> <br/>
<asp:ListItem Text ="ma12" Value="ma12" /> <br/>
</asp:DropDownList>

What code do I add to the following, so that when I select jf12, this code works:

protected void DropDownList1_SelectedIndexChanged1(object sender, EventArgs e)<br/>
<br/>
{<br/>
{<br/>
<br/>
SPWeb web = SPContext.Current.Web;<br/>
SPList list = web.Lists["DailyCashTakings"];<br/>
//SPListItemCollection items = list.Items;<br/>
<br/>
SPQuery query = new SPQuery();<br/>
query.Query = @"<Where><br/>
<Eq><br/>
<FieldRef Name=Period/><br/>
<Value Type=Text>jf12 </Value><br/>
</Eq><br/>
</Where>";<br/>
SPListItemCollection items = list.GetItems(query);<br/>
List<account> lstAccount = new List<account>();<br/>
account acc = new account();<br/>
<br/>
foreach (SPListItem item in items)<br/>
{<br/>
if (!string.IsNullOrEmpty(Convert.ToString(item["TillTotal"])))<br/>
{<br/>
acc.TillTotal += float.Parse(item["TillTotal"].ToString());<br/>
}<br/>
}<br/>
<br/>
<br/>
lstAccount.Add(acc);<br/>
grid.DataSource = lstAccount;<br/>
grid.DataBind();<br/>
}<br/>
}<br/>
<br/>
}<br/>
public class account<br/>
{<br/>
public float TillTotal { get; set; }<br/>
<br/>
}<br/>
}<br/>

AND WHEN I select ma12, then the above code works (but the CALM query searches for ma12 instead of jf12).

Many thanks!

Zuke <hr class="sig zuke collins

View the full article
 
Back
Top