如何解决'并非所有代码路径都返回数据'?

时间:2015-09-11 17:18:36

标签: c# asp.net

   private DataSet getData(HiddenField sDate, HiddenField eDate)
{

    jQueryUICalendar1.Text = sDate.Value;
    jQueryUICalendar2.Text = eDate.Value;

}



<label>Report Start Date:&nbsp;<asp:HiddenField ClientIDMode="Static" runat="server" Visible="true" id="sDate"  Value="" /><asp:TextBox runat="server" inputtype="Date" size="25" value="Click to select start date..."  ID="jQueryUICalendar1" ControlID="jQueryUICalendar1" TextMode="SingleLine" MaxLength="10" Rows="1" ClientIDMode="Static" AutoPostBack="True" ViewStateMode="Enabled"></asp:TextBox></label>
        &nbsp;<label>Report End Date:&nbsp;<asp:HiddenField ClientIDMode="Static" runat="server" Visible="true"  id="eDate" Value=""  /><asp:TextBox runat="server" inputtype="Date" size="25" value="Click to select end date..." ID="jQueryUICalendar2" ControlID="jQueryUICalendar2" TextMode="SingleLine" MaxLength="10" Rows="1" ClientIDMode="Static" AutoPostBack="True" ViewStateMode="Enabled"></asp:TextBox></label>
&#13;
&#13;
&#13;

我试图弄明白为什么&get39数据&#39;不从HiddenField返回任何值。我需要对我的c0de做什么让getData返回适当的值(例如,jQueryUICalendar1,jQueryUICalendar2)

2 个答案:

答案 0 :(得分:2)

问题是你已经声明了'DataSet'的返回类型,但是你的函数没有返回值。将返回类型更改为void(表示没有返回类型)或让函数返回正确的类型/值。

答案 1 :(得分:0)

由于您没有返回DataSet,请将方法设置为void

private void getData(HiddenField sDate, HiddenField eDate)  // <  -- return void
{
    jQueryUICalendar1.Text = sDate.Value;
    jQueryUICalendar2.Text = eDate.Value;
}

或者只是返回DataSet

private DataSet getData(HiddenField sDate, HiddenField eDate)
{
    jQueryUICalendar1.Text = sDate.Value;
    jQueryUICalendar2.Text = eDate.Value;

    DataSet myReturn = new DataSet();
    // Do things with myReturn
    return myReturn;
}