0

p1.aspx に次のドロップダウンがあります。

<select id="ListBoxViewType" style="width:160px;font-family:Tahoma;visibility:hidden;">
                        <option value="Amendment">Amendment</option>
                        <option value="Agreement">Full Terms Amendment</option>
                        <option value="Both">Both</option>
                    </select>

p2.asmx.cs でその値を取得する必要があります。

if ( <insert something like this: ListBoxViewType.Value=="Amendment">)
                            {
                                fileName = chReadData.ContractNumber +"_Amendment" +"-" + chReadData.DisplaySupplementNumber;
                                description = "Amendment for " + chReadData.ContractNumber + "-" + chReadData.DisplaySupplementNumber + " (\"" + chReadData.ContractDescription + "\")";
                            }
                            else 
                            {
                                fileName = chReadData.ContractNumber +"_Full_Amendment" +"-" + chReadData.DisplaySupplementNumber;
                                description = "Amendment for " + chReadData.ContractNumber + "-" + chReadData.DisplaySupplementNumber + " (\"" + chReadData.ContractDescription + "\")";
                            }
4

1 に答える 1

1

runat="server"select要素に追加するだけです:

<select id="ListBoxViewType" runat="server" style="width:160px;font-family:Tahoma;visibility:hidden;">
                    <option value="Amendment">Amendment</option>
                    <option value="Agreement">Full Terms Amendment</option>
                    <option value="Both">Both</option>
                </select>

選択した値を取得するには、次を使用できます。

this.ListBoxViewType.SelectedIndex

DropDownListさらに、代わりにコントロールを使用することを検討する必要があります。

<asp:DropDownList ID="ListBoxViewType" runat="server"....

選択したアイテムにアクセスするには:

this.ListBoxViewType.SelectedValue
this.ListBoxViewType.SelectedItem.Text
this.ListBoxViewType.SelectedItem.Value
于 2012-08-10T01:51:12.340 に答える