Click here to Skip to main content
15,882,113 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
when I debug this then there is the error "INPUT STRING WAS NOT IN CORRECT FORMAT"
CODE PATH IS --
protected void ddl_GroupName_SelectedIndexChanged(object sender, EventArgs e)
{
int aa = Convert.ToInt32(ddl_GroupName.SelectedValue);
bind_linkedVideo(aa);
}

BELOW IS THE ALL CODE-
------------------------------------------------------------------------------------------------








protected void Page_Load(object sender, EventArgs e)
{
if (Session["userid"] != null && Session["userid"].ToString() != string.Empty)
{
if (!IsPostBack)
{
opencms();
bind_audioFile();
bind_linkedVideo(0);
}
}
else
{
Response.Redirect("login.aspx");
}
}

protected void btnUploadCancel_Click(object sender, EventArgs e)
{
ddl_GroupName.SelectedIndex = 0;
ddl_Video.SelectedIndex = 0;
}

public void bind_group()
{
SqlDataAdapter da = new SqlDataAdapter("select group_id, group_title from VideoCategory", con);
DataSet ds = new DataSet();
da.Fill(ds);
if (ds != null && ds.Tables[0].Rows.Count > 0)
{
ddl_GroupName.DataSource = ds.Tables[0];
ddl_GroupName.DataTextField = "group_title";
ddl_GroupName.DataValueField = "group_id";
ddl_GroupName.DataBind();
ddl_GroupName.Items.Insert(0, "Please select");
}
}

public void bind_linkedVideo(int group_id)
{
SqlDataAdapter da = new SqlDataAdapter("select video_id, Video_name from UploadVideo where group_id = " + group_id + " and type = 1", con);
DataSet ds = new DataSet();
da.Fill(ds);
if (ds != null && ds.Tables[0].Rows.Count > 0)
{
ddl_Video.DataSource = ds.Tables[0];
ddl_Video.DataTextField = "Video_name";
ddl_Video.DataValueField = "video_id";
ddl_Video.DataBind();
ddl_Video.Items.Insert(0, "Please select");
}
}

protected void ddl_audiofile_SelectedIndexChanged(object sender, EventArgs e)
{
bind_group();
}

protected void ddl_GroupName_SelectedIndexChanged(object sender, EventArgs e)
{
int aa = Convert.ToInt32(ddl_GroupName.SelectedValue);
bind_linkedVideo(aa);
}
Posted
Updated 28-May-13 0:55am
v5
Comments
Varun Sareen 28-May-13 2:34am    
Please paste the actual code in which you are facing error.
Orcun Iyigun 28-May-13 2:54am    
I think you have a control named UploadDate and at the same in your btnUpload click event you also defined a string named as UploadDate?

I'm not convinced that is your exact error message: you do declare a variable called "UploadDate" in your click event handler, but as a string. Since a string does not have a SelectedDate property, I think you are getting confused.
Look at the line with the error:
C#
DateTime upload_date = UploadDate.SelectedDate.ToShortDateString();

1) UploadDate is a string, so it doesn't have a SelectedDate Property, so you probably want a different variable, or a different type
2) Even if it did, since you create an initialize it in the same method, it won't have a SelectedDate that the user wanted.
3) Since you then convert the SelectedDate to a string, you can't stick the resulting value into a DateTime anyway unless you Parse or TryParse it.

Take a step back, look a your overall code, and try to work out what you are trying to do. I think you are focusing on details which are hiding the bigger picture.
 
Share this answer
 
check your designer page
do you have a control which have id = "UploadDate"? and make sure you have write runat = "server" for that control
Happy Coding!
:)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900