Showing posts with label bound. Show all posts
Showing posts with label bound. Show all posts

Monday, March 12, 2012

Programming databaseconnections?

Hi!

I want some tutorials on how to actually program database applications. Everything seems so bound with the data controls provided by Visual Studio and coming from PHP I don't like to not have full control over my applications. So where can I learn about creating my own database applications without using repeater, gridview or formview?

Thank you in advance!

yes data controls can be over-welming and I see many instances where the pursuit of them consumes more effort that a more procedural approach. Coming from PHO, have you looked at http://www.learn2asp.net/php/Campaign.aspx - these should help your transition to ASP.NET from PHP.

There are also some good tutorials on programming database applications at http://www.asp.net/learn/videos/default.aspx?tabid=63

Programmatically Specify SqlDataSource Parameters

I have a GridView bound to a SqlDataSource. On page load I would like to programmatically specify a SelectParameter value based on the role of the user. This SelectParameter will be used in my WHERE clause. The closest post I can find ishttp://forums.asp.net/thread/1233258.aspx but no answer was posted.

What code would I use to modify a SelectParameters value? Is it possible to reference a parameter by name (SqlDataSource1.SelectParameters["usertype"]) or does it have to be by index? (SqlDataSource1.SelectParameters[0])

Alternatively, perhaps I'm going about this in the wrong way, is there a better way to have dynamic GridView content based on the role of the user?

Thank you very much for your help.

Yes, you can set the value of a select parameters by name, for example
SqlDataSource1.SelectParameters["usertype"].DefaultValue ="role"
|||

Both parameter name and index are working here.

protected

void Page_Load(object sender,EventArgs e)

{

SqlDataSource1.SelectParameters[0].DefaultValue=

"yourvalue";

or

SqlDataSource1.SelectParameters["usertype"].DefaultValue="yourvalue";

}

|||

You can also set the value in the SqlDataSource_Selecting event via the e parameter:

Private Sub SqlDataSource1_Selecting(stuff)

e.command.paramter("param1").value=something

end sub