How to fire an event when user change a dropdownlist inside an asp.net listview? -



How to fire an event when user change a dropdownlist inside an asp.net listview? -

i have listview utilize gridview. within itemtemplate have 'modifyble' field, dropdownlist.

i fire 'save' event when user alter dropdownlist. know have set autopostback = true of dropdownlist don't know how fire event because visual studio don't allow me create 'on alter event' of dropdownlist when within listview.

this code example

<asp:listview id="lvdmr" runat="server" datasourceid="dsdmr" datakeynames="id"> <itemtemplate> <table style="width: 100%;" cellspacing="0" cellpadding="8"> <tr style="width: 100%;"> <td class="colonna-griglia" style="width: 5%;"> <%# convert.todatetime(eval("data_rilevazione")).tostring("d") %> </td> <td class="colonna-griglia"> <%# eval("rivista")%> </td> <td class="colonna-griglia"> <asp:dropdownlist runat="server" id="mycombobox" datasourceid="dsagenti" datatextfield="customer" datavaluefield="customer" width="150px" autopostback="true"> </asp:dropdownlist> </td> ... .... </asp:listview>

you may not in designer view, if straight add together event handler work. next code snippet this.

add onselectedindexchanged="mycombobox_selectedindexchanged" mycombobox. <asp:dropdownlist runat="server" id="mycombobox" datasourceid="dsagenti" datatextfield="customer" datavaluefield="customer" width="150px" autopostback="true" onselectedindexchanged="mycombobox_selectedindexchanged"> </asp:dropdownlist> next in serverside , utilize next event handler. protected void mycombobox_selectedindexchanged(object sender, eventargs e) { dropdownlist ddllistfind = (dropdownlist)sender; listviewitem item1 = (listviewitem)ddllistfind.namingcontainer; // item1, current row of listview, hold dropdownlist caused postback. }

more help - http://forums.asp.net/t/1357900.aspx?selectedindexchanged+of+a+dropdownlist+which+is+inside+a+listview

asp.net listview

Comments

Popular posts from this blog

php - How to pass multiple values from url -

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

database - php search bar when I press submit with nothing in the search bar it shows all the data -