SUPER_USER SUPER_USER - 5 months ago 16
HTML Question

Calendar ID in linq

I try to get calendar ID in LINQ .. So I try this query

T1 ts = new T1();
var list1 = ts.table2.ToList();
var list1 = ts.table2.ToList();
var dq = (from reg_data in list1
join re in ts.table1 on reg_Data.RID equals re.RID
where reg_data.RID == Convert.ToInt32(regiondrop.SelectedValue)
|| (re.startdate == fromdate.Value && re.enddate == todate.Value)
orderby reg_data.OName
select new
{
ID = reg_data.ID,
OName = reg_data.OName,
RegNo = reg_data.RegNo,
RID = reg_data.RID
}).ToList();
GridView1.DataSource = dq;
GridView1.DataBind();


But there is error in
fromdate
and
todate
:


The name 'todate' does not exist in the current context

The name 'fromdate' does not exist in the current context


HTML:

<input type="text" ID="fromdate" />
<input type="text" ID="todate" />


So how I get this
fromdate
and
todate
in query?

Any solution please?

Answer

If you want to make HTML elements in ASP.NET programmable, add a runat="server" attribute to the HTML element:

<input type="text" ID="fromdate" runat="server"/> 

Also you could use Server Controls for this purpose instead.

Comments