TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
shifa Ali
NA
18
2.7k
no value is sent to drop down
Jul 4 2016 4:29 AM
{
if (!this.IsPostBack)
{
this.BindGrid();
}
}
protected void btnSubmitQuery_Click(object sender, EventArgs e)
{
BindGrid();
}
private void BindGrid()
{
{ con = new SqlConnection(ConfigurationManager.ConnectionStrings["CrciketInsighterConnectionString"].ConnectionString);
SqlCommand cmd = new SqlCommand();
{
cmd.CommandText = "getBattingPlayersOA";
cmd.CommandType = CommandType.StoredProcedure;
int formatId = 0, resultId = 0, venueID = 0, teamID = 0;
#region Add Parameters
if (rdODI.Checked)
formatId = 2;
else if (rdT20.Checked)
formatId = 3;
else if (rdTest.Checked)
formatId = 1;
if (WonCheckBox.Checked) resultId = 1;
else if (LostCheckBox.Checked) resultId = 2;
else if (TiedCheckBox.Checked) resultId = 3;
else resultId = 4;
if (rdhome.Checked) venueID = 1;
else if (rdaway.Checked) venueID = 2;
else if (rdAll.Checked) venueID = 4;
else if (rdneutral.Checked) venueID = 3;
string name = "Pakistan";
// here no value is being assigned to a dropdown list .
if (ddTeam.SelectedItem.Value == name) teamID=6;
cmd.Parameters.AddWithValue("@resultId", resultId);
cmd.Parameters.AddWithValue("@venueId", venueID);
cmd.Parameters.AddWithValue("@genderId", 1);
//Error here team ID is not assigned cmd.Parameters.AddWithValue("@teamId",teamID);
cmd.Parameters.AddWithValue("@formatID", 1);
#endregion
using (SqlDataAdapter sda = new SqlDataAdapter())
{
cmd.Connection = con;
sda.SelectCommand = cmd;
using (DataSet ds = new DataSet())
{
sda.Fill(ds);
grdResult.DataSource = ds;
grdResult.DataBind();
}
}
}
}
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
try
{
con.Open();
query = "select * from OA_PlayerBat where Team_ID ='" + ddTeam.SelectedItem + "'";
SqlCommand cmd = new SqlCommand(query, con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
ddTeam.DataSource = ds;
ddTeam.DataBind();
con.Close();
}
catch (Exception ex)
{
Response.Redirect(ex.Message);
}
}
}
}
Issues I am facing:
no value is being set to a drop-down list i have mentioned the lines where the errors are. kindly see if you can help me out in sorting this. Thanks
Reply
Answers (
4
)
bind value on label in .net c#
validation for texteditor