Aspx代码:
<asp:GridView ID="PaperReviewing" runat="server" CellPadding="4" EmptyDataText="There is no Submission"DataKeyNames="PaperId" RowStyle-Wrap="true" OnRowDataBound="PaperReviewing_RowDataBound">
<Columns>
<asp:TemplateField HeaderText="Action" ControlStyle-Width="200px" >
<ItemTemplate>
<br />
<asp:HyperLink ID="HyperLink3" Target="_blank" ForeColor="Black" onclick="javascript:window.open(this.href,'ManuScript Details','resizable=no,scroll bars=yes,status=no,toolbar=yes,height=500,width=700,left=50,top=40');return true;"
NavigateUrl='<%# String.Format("~/EditorsInChief/DownloadSubFileList.aspx?ID={0}", Eval("PaperId")) %>' runat="server">File Inventory</asp:HyperLink>
<br /><asp:HyperLink ID="HyperLink4" Target="_blank" ForeColor="Black" onclick="javascript:window.open(this.href,'ManuScript Details','resizable=no,scroll bars=yes,status=no,toolbar=yes,height=500,width=700,left=50,top=40');return true;"
NavigateUrl='<%# String.Format("~/EditorsInChief/SelectReviewer.aspx?ID={0}", Eval("PaperId")) %>' runat="server">Select Another Reviewer</asp:HyperLink>
<br />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="PaperId" HeaderText="PaperId" InsertVisible="False"
ReadOnly="True" SortExpression="PaperId" Visible="False" />
<asp:BoundField DataField="ManuScriptId" HeaderText="ManuScript Number"
SortExpression="ManuScriptId" />
<asp:BoundField DataField="Type" HeaderText="Article Type" SortExpression="Type" />
<asp:TemplateField HeaderText="Article Title" HeaderStyle-Wrap="true" ItemStyle-Wrap="true" ItemStyle-HorizontalAlign="Left" SortExpression="PaperTitle" ControlStyle-Width="200px">
<ItemTemplate>
<asp:Label ID="Label4" runat="server" Text='<%# Bind("PaperTitle") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="ReviewerName" HeaderText="Reviewer Name" SortExpression="ReviewerName" />
<asp:BoundField DataField="Status" HeaderText="Current Status"
SortExpression="Status" />
<asp:BoundField DataField="CreatedDate" HeaderText="Intital Date Submission" SortExpression="CreatedDate" />
<asp:BoundField DataField="DateReviewInvited" HeaderText="Date Review Invited"
SortExpression="DateReviewInvited" />
<asp:BoundField DataField="DateReviewDue" HeaderText="Date Review Due"
SortExpression="DateReviewDue" />
<asp:TemplateField HeaderText="EIC Decision">
<ItemTemplate>
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="true"
onselectedindexchanged="DropDownList1_SelectedIndexChanged">
<asp:ListItem Selected="True" Text="Choose Option"></asp:ListItem>
<asp:ListItem Text="Accept" Value="Accept"></asp:ListItem>
<asp:ListItem Text="Reject" Value="Reject"></asp:ListItem>
<asp:ListItem Text="Minor Revision" Value="MinorRevision"></asp:ListItem>
<asp:ListItem Text="Major Revision" Value="MajorRevision"></asp:ListItem>
</asp:DropDownList>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" BorderStyle="Double" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<EditRowStyle BackColor="#2461BF" />
<AlternatingRowStyle BackColor="White" />
</asp:GridView>
C#代码:
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) { DropDownList DropDownList1 = (DropDownList)sender; GridViewRow grdrDropDownRow = ((GridViewRow)DropDownList1.Parent.Parent); } protected void PaperReviewing_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { DropDownList ddl = e.Row.FindControl("DropDownList1") as DropDownList; if (ddl != null) { ddl.SelectedIndexChanged += new EventHandler(DropDownList1_SelectedIndexChanged); } } }
drop down selectedindexchanged事件不会触发。我正在尝试执行此操作,因为我的下拉值在运行时更改,在我的数据库值中获取更新。
答案 0 :(得分:3)
删除从PaperReviewing_RowDataBound
添加代码的事件处理程序,因为您已经从标记附加了
在你的页面加载
protected void Page_Load(object sender, EventArgs e)
{
if(!Page.IsPostBack)
{
DataBindGrid();
}
}