0
votes

I inherited an asp.net web page that has a gridview control and an html button on each row in the gridview. I added "onserverclick" so that I could do some stuff at the server when this button is clicked. I can't use the asp button control because the manager wants it this way.

The end result is that I want to set the selected value of a dropdownlist control with a value from the gridview row. I got this working.

Now the problem. I am using an ajax ModalPopupExtender to display a panel as a popup window. But since I added the onservercontrol event, the popup now never displays. If I take off the onserverclick then the popup displays again but then I can't set my dropdownlist aelected value correctly.

I read something about having to do an ajax post. But not sure how to do that. I can post my html and C# code. Let me know what you need to see.

1
Please add some of the code from your application, it will greatly help us help you.TreyE

1 Answers

0
votes

Trey,

Here is the html for my gridview control:

<asp:GridView CssClass="gridClass" 
                                              AlternatingRowStyle-CssClass="gridAlternateItem"
                                              ID="gvMessage" 
                                              HeaderStyle-CssClass="gridHeader" 
                                              runat="server" 
                                              Width="98%" 
                                              ShowHeader="true"
                                              AutoGenerateColumns="false" 
                                              AllowPaging="true" 
                                              AllowSorting="true" 
                                              PageSize="25"
                                              PagerStyle-BackColor="#006699" 
                                              PagerStyle-ForeColor="White" 
                                              CellPadding="0"
                                              CellSpacing="0" 
                                              OnPageIndexChanging="gvMessage_PageIndexChanging" 
                                              OnRowDataBound="gvMessage_RowDataBound" 
                                              OnSorting="gvMessage_Sorting" 
                                              OnSelectedIndexChanged="gvMessage_SelectedIndexChanged">
                                    <Columns>
                                        <asp:TemplateField ItemStyle-Height="20px" HeaderText="Task Date" SortExpression="DATE" HeaderStyle-ForeColor="white">
                                            <ItemStyle Width="15%" HorizontalAlign="Left" CssClass=" gridRow" Wrap="false"/>
                                            <ItemTemplate>
                                                <asp:Label ID="lblDate" runat="server" Text='<%#Eval("Date")%>'></asp:Label>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField ItemStyle-Height="20px" HeaderText="Patient Name" SortExpression="Patient Chart" HeaderStyle-ForeColor="white">
                                            <ItemStyle Width="15%" HorizontalAlign="Left" CssClass=" gridRow" Wrap="false"/>
                                            <ItemTemplate>
                                                <asp:Label ID="lblPatientChart" runat="server" Width="100%"></asp:Label>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField>
                                            <HeaderTemplate>
                                                Staff</HeaderTemplate>
                                            <ItemStyle Width="15%" HorizontalAlign="Left" CssClass="gridRow" />
                                            <ItemTemplate>
                                                <asp:Label ID="lblStaff" runat="server" Width="100%"></asp:Label>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField ItemStyle-Height="20px" HeaderText="Task Type" SortExpression="Message Type" HeaderStyle-ForeColor="white">
                                            <ItemStyle Width="30%" HorizontalAlign="Left" CssClass=" gridRow" Wrap="false"/>
                                            <ItemTemplate>
                                                <asp:Label ID="lblTaskType" runat="server" Width="100%"></asp:Label>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField>
                                            <HeaderStyle Width="10%" />
                                            <ItemStyle Width="10%" CssClass="gridRow" />
                                            <HeaderTemplate>
                                                Task Notes</HeaderTemplate>
                                            <ItemTemplate>
                                                <input type="button" runat="server" id="btnTaskNotes" name="ADD" class="button" value="Note" style="width: 100px" onserverclick="OnServerClick"/>      
                                                <%--<input type="button" runat="server" id="btnTaskNotes" name="ADD" class="button" value="Note" style="width: 100px"/> --%>                                          
                                                <input type="hidden" runat="server" id="hidFkid" />
                                                <input type="hidden" runat="server" id="hidPhysManagementId" />
                                                <input type="hidden" runat="server" id="hidComments" />
                                                <input type="hidden" runat="server" id="hidClinicalNote" />
                                                <input type="hidden" id="hidPkPhoneId" runat="server" />
                                                <input type="hidden" runat="server" id="hidFK_Practitioner_Id" />
                                            </ItemTemplate>
                                        </asp:TemplateField>

                                        <asp:TemplateField ItemStyle-Height="20px" HeaderText="Delete" HeaderStyle-ForeColor="white">
                                            <ItemStyle Width="10%" HorizontalAlign="Center" CssClass=" gridRow" Wrap="false"/>
                                            <HeaderTemplate>
                                                <input type=checkbox id="chkDeleteAll" runat=server onclick="CheckAll(this.id)"/>
                                                <input type=button id="btnDelete" runat=server value="Delete" class="classButton" style="width: 60%;" onclick="DeleteMsg();"/></HeaderTemplate>
                                            <ItemTemplate>
                                                <input type=checkbox id="chkDelete" runat=server />
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField>
                                            <ItemTemplate>
                                                <asp:Label ID="lblFK_Practitioner_Id" runat="server" Visible="false" Text='<%#Eval("FK_Practitioner_Id")%>'></asp:Label>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                    </Columns>
                                </asp:GridView>

What else do you need to for me to post?