user35
user35

Reputation: 468

Can we declare variable inside div tag in asp.net?

I have the following div:

 <div id="5" style=" display:none; " >               
   <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
     ConnectionString="<%$ ConnectionStrings:schoolConnectionString %>" 
     SelectCommand="SELECT * FROM [class] where classid=4 "></asp:SqlDataSource>
</div>

As you can see i am giving the classid = 4 manually by myself in the where condition.What I want is to give it dynamically according to to click made. What i am trying to do here is declare a variable inside div that will be assigned the value as per the click on the link and assign that variable to classid as classid=myvariable.

So my question is:
1.How to declare a variable inside div in asp.net?
2.How to assign classid=variable?

Upvotes: 0

Views: 467

Answers (1)

3dd
3dd

Reputation: 2530

See the following article for an example of how this should be done

http://msdn.microsoft.com/en-us/library/vstudio/z72eefad(v=vs.100).aspx

You're code could be written something like this

SELECT * FROM [class] where classid=@classId

Then declare the parameter using

<SelectParameters> <asp:Parameter Name="classid" Type="Int32" DefaultValue="0" /> </SelectParameters>

Upvotes: 1

Related Questions