SUPER_USER SUPER_USER - 2 years ago 86
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
GridView1.DataSource = dq;

But there is error in

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

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


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

So how I get this
in query?

Any solution please?

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download