question

INNET-7406 avatar image
0 Votes"
INNET-7406 asked SeanFang-MSFT edited

avoid full page postback on dropdow selected index changed...

I have a gridview wrapped around update panel. I have two template fields in gridview as follows:

<asp:TemplateField HeaderText="User">

                                     <ItemTemplate>
                                            
                                          <asp:DropDownList ID="ddlUsers" runat="server"
                                                         AutoPostBack="true" OnSelectedIndexChanged="ddlUsers_SelectedIndexChanged"/>
                                           
                  
                                     </ItemTemplate>
                                 </asp:TemplateField>
                                 <asp:TemplateField HeaderText="Status" >
                                     <ItemTemplate>
                                         <div class="panel panel-default">
                                             <div class="panel-heading"><asp:Literal runat="server" ID="lblSelectedUser" /></div>
                                             <ul class="list-group">
                                                 <li class="list-group-item"><span class="strong">ID</span>: <asp:Literal runat="server" ID="lblId" /></li>
                                                 <li class="list-group-item"><span class="strong">Name</span>: <asp:Literal runat="server" ID="lblFullName"></asp:Literal></li>
                                                 <li class="list-group-item"><span class="strong">Email</span>: <asp:Literal runat="server" ID="lblEmail"></asp:Literal></li>
                                             </ul>
                                         </div>
                                     </ItemTemplate>
                                 </asp:TemplateField>


I can't set autopostback to "false" for the ddlUsers as I am updating the literal controls text values for the other template field properties in the ddlUsers_SelectedIndexChanged event. Is there a way to not cause a postback but still run the indexchanged event to update the other values in literal controls?

The dropdown text value is stored as Lastname,FirstName [ID] (Email) and somtimes as Lastname(Middle),Firstname [ID] (Email)

Is there a way to update the lblId, lblFullName and lblEmail to be the values from the dropdown in javascript and change the row for that gridview to be a different color without the selectedIndexChanged event firing?
so if the dropdown selected index is changed to "Gabriel, Josh [12345] (gabrielJ@test.com)" then the lblId would be 12345, lblFullName text would be Gabriel, Josh and lblEmail.text would be gabrielJ@test.com and the row backgroudn color would be lightgreen or something to denote that dropdown selection has been changed for the row.



dotnet-csharpdotnet-aspnet-webforms
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

LuisRemun-0975 avatar image
0 Votes"
LuisRemun-0975 answered

Hello,

If you can post the entire updatepanel it will be helpful. It could be a lot of things, maybe you haven't configured the trigger element of the update panel the to fire with the dropdownlist event, i.e.:
<Triggers>
<asp:AsyncPostBackTrigger ControlID="ddlUsers"
EventName="SelectedIndexChanged" />
</Triggers>

Regards

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.