Hi m.goodarzi,
Here i have created sample that full fill your requirement.
SQL
CREATE PROCEDURE GetPriceBasedOnCourse
@Name VARCHAR(20)
AS
BEGIN
DECLARE @Cources AS TABLE(ID INT IDENTITY,NAME VARCHAR(50),LEVEL INT,PRICE INT)
INSERT INTO @Cources VALUES('Android',1,25000)
INSERT INTO @Cources VALUES('Java',2,35000)
INSERT INTO @Cources VALUES('C#',1,18000)
INSERT INTO @Cources VALUES('Asp.Net',3,22000)
INSERT INTO @Cources VALUES('SQL',4,12000)
SELECT * FROM @Cources WHERE NAME = @Name
END
HTML
<div>
<asp:RadioButtonList runat="server" ID="rbCources" AutoPostBack="true" OnSelectedIndexChanged="OnIndexChanged">
<asp:ListItem Text="Android" />
<asp:ListItem Text="Java" />
<asp:ListItem Text="C#" />
<asp:ListItem Text="Asp.Net" />
<asp:ListItem Text="SQL" />
</asp:RadioButtonList>
<br />
Level: <asp:Literal ID="litLevel" runat="server" />
<br />
Price: <asp:Literal ID="litPrice" runat="server" />
</div>
Code
protected void OnIndexChanged(object sender, EventArgs e)
{
string constr = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
using (SqlConnection con = new SqlConnection(constr))
{
con.Open();
using (SqlCommand cmd = new SqlCommand("GetPriceBasedOnCourse", con))
{
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@Name", rbCources.SelectedItem.Text.Trim());
SqlDataReader sdr = cmd.ExecuteReader();
while (sdr.Read())
{
litLevel.Text = sdr["LEVEL"].ToString();
litPrice.Text = sdr["PRICE"].ToString();
}
}
con.Close();
}
}
Screenshot
