Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Web Coding › How to bind data without database source?
New Posts  All Forums:Forum Nav:

How to bind data without database source? - Page 2

post #11 of 16
Do you mean you're using
Code:
<asp:SqlDataSource />
to get your data? If so, you really should learn using SQLDataAdapter or Entity Framework or anything other than SqlDataSource. If you want something quick/basic, SqlDataSource works but as you do more stuff, it's really limited.

But here's one way to get the data then store in a session as a DataTable to work with.
Code:
DataView dv = new DataView();
DataTable dt = new DataTable();
dv = mySqlDataSource.Select(DataSourceSelectArguments.Empty);
dt = dv.ToTable();
Session["products"] = dt;

Note: This is with C#
Main PC
(13 items)
 
  
CPUMotherboardGraphicsRAM
i5 2500k Asus Maximus IV Gene-Z MSI 6950 2gb Unlocked Ref GSkill Ripjaws X 8GB CL8 
Hard DriveOSMonitorKeyboard
Crucial M4 128GB Windows 7 Ult Samsung 24" ToC Das Professional Silent 
PowerCaseMouse
Seasonic X750 Corsair 650d Logitech G700 
  hide details  
Reply
Main PC
(13 items)
 
  
CPUMotherboardGraphicsRAM
i5 2500k Asus Maximus IV Gene-Z MSI 6950 2gb Unlocked Ref GSkill Ripjaws X 8GB CL8 
Hard DriveOSMonitorKeyboard
Crucial M4 128GB Windows 7 Ult Samsung 24" ToC Das Professional Silent 
PowerCaseMouse
Seasonic X750 Corsair 650d Logitech G700 
  hide details  
Reply
post #12 of 16
Thread Starter 
alright thanks, but I think I am getting closer to finish with the object approach. If I can't then I will try your suggestion.
post #13 of 16
Thread Starter 
I got it to work finally with the object approach. I currently have a textbox on the product page to for user to enter a quantity. Currently the box said "how many?". How do I make the text go away when user click on it and how should I implement validation?
post #14 of 16
Quote:
Originally Posted by Buster View Post

I got it to work finally with the object approach. I currently have a textbox on the product page to for user to enter a quantity. Currently the box said "how many?". How do I make the text go away when user click on it and how should I implement validation?

If the textbox has a postback event attached to it, you can change the text programatically on the change event. Otherwise you can use Javascript to check if the value of the textbox has changed and remove the text.

Validation can be done using the ASP.NET Validation controls(RequiredFieldValidator, RegularExpressionValidator, etc.), bind the control to each textbox id and set what rules it should be validated by. More info on Microsoft's site : http://msdn.microsoft.com/en-us/library/aa479013.aspx
Main PC
(13 items)
 
  
CPUMotherboardGraphicsRAM
i5 2500k Asus Maximus IV Gene-Z MSI 6950 2gb Unlocked Ref GSkill Ripjaws X 8GB CL8 
Hard DriveOSMonitorKeyboard
Crucial M4 128GB Windows 7 Ult Samsung 24" ToC Das Professional Silent 
PowerCaseMouse
Seasonic X750 Corsair 650d Logitech G700 
  hide details  
Reply
Main PC
(13 items)
 
  
CPUMotherboardGraphicsRAM
i5 2500k Asus Maximus IV Gene-Z MSI 6950 2gb Unlocked Ref GSkill Ripjaws X 8GB CL8 
Hard DriveOSMonitorKeyboard
Crucial M4 128GB Windows 7 Ult Samsung 24" ToC Das Professional Silent 
PowerCaseMouse
Seasonic X750 Corsair 650d Logitech G700 
  hide details  
Reply
post #15 of 16
Thread Starter 
I found a javascript that will work with a html input box, but couldn't find an example of textbox control.
post #16 of 16
Quote:
Originally Posted by Buster View Post

I found a javascript that will work with a html input box, but couldn't find an example of textbox control.

You just need to change the javascript to target the client_ID of the textbox control - The textbox control renders as an input tag when the page is requested.
Main PC
(13 items)
 
  
CPUMotherboardGraphicsRAM
i5 2500k Asus Maximus IV Gene-Z MSI 6950 2gb Unlocked Ref GSkill Ripjaws X 8GB CL8 
Hard DriveOSMonitorKeyboard
Crucial M4 128GB Windows 7 Ult Samsung 24" ToC Das Professional Silent 
PowerCaseMouse
Seasonic X750 Corsair 650d Logitech G700 
  hide details  
Reply
Main PC
(13 items)
 
  
CPUMotherboardGraphicsRAM
i5 2500k Asus Maximus IV Gene-Z MSI 6950 2gb Unlocked Ref GSkill Ripjaws X 8GB CL8 
Hard DriveOSMonitorKeyboard
Crucial M4 128GB Windows 7 Ult Samsung 24" ToC Das Professional Silent 
PowerCaseMouse
Seasonic X750 Corsair 650d Logitech G700 
  hide details  
Reply
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Web Coding
Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Web Coding › How to bind data without database source?