Friday, February 12, 2010

How can I access a control in ASP.NET with C# in LoginView?

I have a page, the hierarchy goes like this:


LoginView1 --%26gt; DetailsView1 --%26gt; TemplateField --%26gt; Calendar1





How can I access the Calendar1 in the default.aspx.cs page?


For example I want to select the SQL insert query in the SqlDataSource1 control to define that the date is selected from Calendar1.How can I access a control in ASP.NET with C# in LoginView?
This question makes absolutely no sense as worded.





If what you mean is you want to provide to a SQLDataSource control the SelectedDate value from your Calendar1 control, that's simple enough, and you don't need to do it in codebehind, you can do it in the control itself.





%26lt;asp:SqlDataSource id=';mySQL'; runat=';server'; InsertCommand = ';INSERT INTO mytable (dateFieldA) VALUES (@calendar1)';%26gt;


%26lt;insertparameters%26gt;


%26lt;asp:controlparameter name=';calendar1'; controlid=';Calendar1'; propertyname = ';selecteddate'; /%26gt;


%26lt;/insertparameters%26gt;


%26lt;/asp:SqlDataSource%26gt;

No comments:

Post a Comment