Multiply

Posted by Pokuri31 under ASP.NET on 11/14/2008 | Views : 6053 | Status : [Member] | Replies : 3
how to multiply one value from combobox and another one is textbox on dotnet?




//string str = ((textBox1.Text).ToString() * (comboBox2.SelectedItem).ToString());
string str = comboBox2.SelectedItem.ToString();
float f = float.Parse(textBox1.Text);




Responses

Posted by: Jayakumars on: 9/30/2012 [Member] [MVP] Bronze | Points: 25

Up
0
Down
hi

try this code

string str = Convert.ToInt32(comboBox2.SelectedItem.Text);
float f = Convert.ToDecimal (textBox1.Text);


Mark as Answer if its helpful to you

Pokuri31, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Jayakumars on: 9/30/2012 [Member] [MVP] Bronze | Points: 25

Up
0
Down
hi

Please mark as answer Resolved Posts if it helpful to you.

Mark as Answer if its helpful to you

Pokuri31, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: SheoNarayan on: 11/14/2008 [Administrator] HonoraryPlatinum

Up
0
Down
Here is the code with example.

Your .aspx code

<asp:DropDownList ID="drop1" runat="server">

<asp:ListItem Text="1" Value="1" />
<asp:ListItem Text="2" Value="2" />
<asp:ListItem Text="3" Value="3" />
</asp:DropDownList>

<asp:TextBox ID="txtText" runat="server" ></asp:TextBox>

<asp:Label ID="lblMessagE" runat="server"></asp:Label>
<asp:Button ID="btnSub" runat="server" Text="Submit" OnClick="SubmitMe" />


Code behind code

 protected void SubmitMe(object sender, EventArgs e)

{
int i = int.Parse(drop1.SelectedValue);
int j = int.Parse(txtText.Text);
int k = i * j;
lblMessagE.Text = k.ToString();
}


Above code should write multiplication result based on your selection in the label. You can also download the sample attached.
 Download source file

Regards,
Sheo Narayan
http://www.dotnetfunda.com

Pokuri31, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response