views:

8

answers:

0

Hey I have a gridview with 1 column where the user can edit the value.

This worked fine

<asp:GridView ID="grdPropertyList" runat="server" DataKeyNames="id" DataSourceID="SqlDataSource1" AutoGenerateColumns="False" CssClass="style3 caption" AlternatingRowStyle-CssClass="alt" HeaderStyle-CssClass="header_req" BorderWidth="0px" GridLines="None" AllowPaging="False"  EmptyDataText="No records.">    
    <Columns>   
            <asp:BoundField ReadOnly="True" HeaderText="Property Id" HeaderStyle-Width="50px"
                InsertVisible="False" DataField="id"
                SortExpression="id"></asp:BoundField>

                <asp:TemplateField HeaderText="Property Address" SortExpression="address" HeaderStyle-Width="200px">
                <ItemTemplate>   
                <span title='<%# FormValidation.ReverseXSS(Eval("address").ToString())%>'>
                <a href="Commercial_Sales_Edit_Property.aspx?ID=<%# Eval("id")%>">
                <%# M1Utils.CutString(FormValidation.ReverseXSS(Eval("address").ToString()), 30)%>
                </a>
                </span> 
                </ItemTemplate>                     
            </asp:TemplateField>  

                <asp:BoundField ReadOnly="True" HeaderText="Building Type" 
                DataField="buildingType" 
                SortExpression="buildingType"></asp:BoundField>
            <asp:BoundField HeaderText="Sequence" 
                DataField="sortOrder" 
                SortExpression="sortOrder"></asp:BoundField>


But the list was to long so I added a dropdown which the user can select a value to filter the list to a subset.

So I also have

protected void propertyTypeId_SelectedIndexChanged(object sender, EventArgs e)
{
    if (propertyTypeId.SelectedIndex > 0)
    {
        if (SqlDataSource1.FilterExpression.Length > 0)
            SqlDataSource1.FilterExpression = SqlDataSource1.FilterExpression + " AND (buildingType = '" + FormValidation.CutOffXSS(propertyTypeId.SelectedValue) + "') ";
        else
            SqlDataSource1.FilterExpression = " (buildingType = '" + FormValidation.CutOffXSS(propertyTypeId.SelectedValue) + "') ";
    }
    if (SqlDataSource1.FilterExpression.ToString().Length > 0)
    {
        grdPropertyList.DataBind();
    }
}

Problem is..

1) I select a value in dropdown, i.e only show Building Type "Commerce" 2) My gridview shows only "Commerce" Records 3) I click on edit, and update the value on the 1st record in this list and press update 4) The gridview refreshes and the filter list is maintained but the value of the one I updated is still the old value didnt update.

Any Help ?