将下拉值传递给函数时出错 [英] Error while passing dropdown value to the function

查看:61
本文介绍了将下拉值传递给函数时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将下拉值作为参数传递给函数



我的代码是



< pre lang =cs> protected void PayWithPayPal( string 金额,字符串 itemInfo,字符串名称,
string phone, string email, string currency)







我正在传递这样的价值





 受保护  void  btnPay_AsPerYourChoice( object  sender,EventArgs e)
{
PayWithPayPal(txtAmount,txtPurpose,txtName,txtPhone,txtEmailId,ToString()。(ddlCurrency.SelectedItem));
}





下拉代码是



 <   asp:DropDownList     runat   =  server < span class =code-attribute>   ID   =  ddlCurrency   样式  =   margin-left:42px; 
width:204px; background-image:transparent url('../ images / txtBoxbg.jpg')no-repeat ;
>
< asp:ListItem > - 选择 - < / asp:ListItem >
< asp:ListItem > INR < / asp:ListItem >
< asp:ListItem > USD < / asp:ListItem >
< asp:ListItem > EURO < / asp:ListItem >
< asp:Li stItem > Pound < / asp :ListItem >
< / asp:DropDownList >







获取错误

:标识符必需

解决方案

试试这种方式 -

< pre lang =c#> PayWithPayPal(txtAmount.Text,txtPurpose.Text,txtName.Text,txtPhone.Text,txtEmailId.Text,ddlCurrency.SelectedItem.Text)


How to Pass value of dropdown to the function as paramete

my code is

protected void PayWithPayPal(string amount, string itemInfo, string name,
         string phone, string email, string currency)




and i am passsing value like this


protected void btnPay_AsPerYourChoice(object sender, EventArgs e)
   {
       PayWithPayPal(txtAmount,txtPurpose,txtName,txtPhone,txtEmailId,ToString().(ddlCurrency.SelectedItem));
   }



Dropdown code is

<asp:DropDownList runat="server" ID="ddlCurrency" Style="margin-left: 42px;
        width: 204px; background-image: transparent url('../images/txtBoxbg.jpg') no-repeat;">
        <asp:ListItem>- Select -</asp:ListItem>
        <asp:ListItem>INR</asp:ListItem>
        <asp:ListItem>USD</asp:ListItem>
        <asp:ListItem>EURO</asp:ListItem>
        <asp:ListItem>Pound</asp:ListItem>
    </asp:DropDownList>




Getting error
:Identifier Required

解决方案

Try this way -

PayWithPayPal(txtAmount.Text,txtPurpose.Text,txtName.Text,txtPhone.Text,txtEmailId.Text,ddlCurrency.SelectedItem.Text)


这篇关于将下拉值传递给函数时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆