Click here to Skip to main content
16,005,682 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: calling a codebehind function from javascript using ajax Pin
Imran Khan Pathan15-Aug-07 23:13
Imran Khan Pathan15-Aug-07 23:13 
QuestionHow to change a template and Skin to ASP.NET page Pin
mangrovecm15-Aug-07 18:27
mangrovecm15-Aug-07 18:27 
QuestionCheckboxlist Pin
n_gchaitra15-Aug-07 17:16
n_gchaitra15-Aug-07 17:16 
AnswerRe: Checkboxlist Pin
Michael Sync15-Aug-07 17:42
Michael Sync15-Aug-07 17:42 
GeneralRe: Checkboxlist Pin
n_gchaitra15-Aug-07 17:57
n_gchaitra15-Aug-07 17:57 
GeneralRe: Checkboxlist Pin
Michael Sync15-Aug-07 20:03
Michael Sync15-Aug-07 20:03 
GeneralRe: Checkboxlist Pin
n_gchaitra15-Aug-07 23:09
n_gchaitra15-Aug-07 23:09 
GeneralRe: Checkboxlist Pin
Michael Sync15-Aug-07 23:41
Michael Sync15-Aug-07 23:41 
Database should be a helper class that return the dataset after retrieving the data from database.

n_gchaitra wrote:
I want only matching values to get checked.


What you meant is that there are the values (1,2,3) in database. There are 5 items (1,2,3,4,5) shown in ListBox. After retrieving the data (1,2,4) from database, you want the items (1,2,3) to be checked. Is it what you want?

Let's Database.GetAllItems(); will return all data (1,2,3,4,5) from database.

this method Database.GetStoredItems() will return all saved value as a comma seperated value (eg: 1,2,3)


eg:

public class Database{<br />
  public static string GetStoredItems(){<br />
    //Get the data from Database<br />
    //Return those data as comman seperated value<br />
    return str;  // 1,2,3<br />
  }<br />
  public static DataSet GetAllItems()(){<br />
    //Get the data from Database<br />
    //Return those data as DataSet<br />
    return ds;  // 1,2,3,4,5<br />
  }<br />
} 


then, bind it to Listbox. (So, 1,2,3,4,5 will be shown in Listbox. )
<br />
Listbox.DataSource = Database.GetAllItems();<br />
Listbox.DataBind();


then, get the saved values from database. (In our case, we will get "1,2,3"). Split to string array. loop through the listbox and string array to find the match. If match found, we set itm.Checked = true;

string[] storedValues = Database.GetStoredItems().Split(",");<br />
<br />
foreach(string val in storedValues){<br />
foreach ( ListItem itm in ListBox1.Items ){<br />
if(itm.Value == val){<br />
itm.Checked = true;<br />
}<br />
}<br />
}


Is the way I understand correct?

Hopefully, you got my point...

Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)

If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you. Smile | :)

GeneralRe: Checkboxlist Pin
n_gchaitra16-Aug-07 23:47
n_gchaitra16-Aug-07 23:47 
GeneralRe: Checkboxlist Pin
Michael Sync17-Aug-07 2:20
Michael Sync17-Aug-07 2:20 
GeneralRe: Checkboxlist Pin
n_gchaitra17-Aug-07 17:28
n_gchaitra17-Aug-07 17:28 
QuestionCan I remove Master Page in the program? Pin
J Liang15-Aug-07 16:57
J Liang15-Aug-07 16:57 
AnswerRe: Can I remove Master Page in the program? Pin
Steve Echols15-Aug-07 18:16
Steve Echols15-Aug-07 18:16 
AnswerRe: Can I remove Master Page in the program? Pin
nandhububbly15-Aug-07 19:23
nandhububbly15-Aug-07 19:23 
GeneralRe: Can I remove Master Page in the program? Pin
Michael Sync15-Aug-07 20:04
Michael Sync15-Aug-07 20:04 
AnswerRe: Can I remove Master Page in the program? [modified] Pin
Michael Sync15-Aug-07 19:57
Michael Sync15-Aug-07 19:57 
AnswerRe: Can I remove Master Page in the program? Pin
ganeshvittal15-Aug-07 20:57
ganeshvittal15-Aug-07 20:57 
QuestionCan't create ASP controls from shared function Pin
chris_wanaka15-Aug-07 16:51
chris_wanaka15-Aug-07 16:51 
AnswerRe: Can't create ASP controls from shared function Pin
Michael Sync15-Aug-07 17:30
Michael Sync15-Aug-07 17:30 
GeneralRe: Can't create ASP controls from shared function Pin
chris_wanaka15-Aug-07 18:10
chris_wanaka15-Aug-07 18:10 
QuestionSetup project with custom actions Pin
steve_rm15-Aug-07 7:47
steve_rm15-Aug-07 7:47 
Questionmisc asp.net questions [modified] Pin
algoaddict15-Aug-07 7:27
algoaddict15-Aug-07 7:27 
AnswerRe: misc asp.net questions Pin
Jpuckett15-Aug-07 7:44
Jpuckett15-Aug-07 7:44 
GeneralRe: misc asp.net questions Pin
algoaddict15-Aug-07 8:16
algoaddict15-Aug-07 8:16 
GeneralRe: misc asp.net questions Pin
Jpuckett15-Aug-07 8:54
Jpuckett15-Aug-07 8:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.