|
2
|
Other Software / Developer's Corner / Rearranging one item within a dataset
|
on: December 15, 2009, 12:55:10 PM
|
I've got a list of people coming in from a stored procedure alphabetically, stored in a dataset, bound to a custom datasource, then displayed in the order that they came in on. Formatted for C# with the GeSHI Syntax Highlighter [ copy or print] protected void gvPhotoGrid_OnItemDataBound(object sender, DataListItemEventArgs e) { if (e.Item.ItemType == ListItemType.AlternatingItem | e.Item.ItemType == ListItemType.Item) { Label l = (Label)e.Item.FindControl("lblTitle"); if (l != null) { string strval = l.Text; string title = _title; if (title == strval) { l.Text = ""; e.Item.Visible = false; } else { title = strval; _title = title; l.Text = "<br/>" + title; e.Item.Visible = true; } } } }
My problem is, two people got a divorce and can't be next to each other. They both have the same last name so by default they would come in to the list right next to each other. So, what would be the logic to display one of the people on the list in a different location without putting them at the bottom or top? Formatted for HTML with the GeSHI Syntax Highlighter [ copy or print] <asp:DataList ID="gvPhotoGrid" runat="server"> <ItemTemplate> <tr id='<%# Eval("DiaLevelName") %>' align="center"> <td colspan="2"><asp:Label ID="lblTitle" Font-Underline="true" Font-Bold="true" runat="server" Text='<%# Bind("DiaLevelName") %>' Visible="true" > </asp:Label> <td><a href='<%# ResolveUrl("gemProfile.aspx?gemid=" + Eval("userID") + "&Name=" + Eval("calendarSearch")) %>'> <asp:Image BorderWidth="0px" ID="Image1" runat="server" AlternateText='<%# Eval("userName") %>' ImageUrl='<%# ResolveUrl("~/images/gemImages/" + Eval("gemImage")) %>' /> <asp:Label runat="server" ID="lblName" Text='<%# Eval("userName") %>' /> </ItemTemplate> </asp:DataList>
|
|
|
|
|
3
|
Other Software / Developer's Corner / Reusing a Custom Gridview Control
|
on: October 21, 2009, 02:52:37 PM
|
|
Greetings!
I've created a Custom Control with a gridview in it. I designed it for page X but I also want to put the control in page Y. However, I set the gridview datasource in the control for what I wanted to display in X, but I need a different datasource in page Y. My Boss tells me I need to expose a property or method that would allow me to pass the datasource in. I haven't a clue where or how to do that.
Any thoughts?
|
|
|
|
|
4
|
Other Software / Developer's Corner / Re: ASP.NET and C# webform. Need help with query to DB
|
on: July 31, 2009, 06:52:13 AM
|
Formatted for C# with the GeSHI Syntax Highlighter [ copy or print] SqlConnection conn; DataSet dataSet = new DataSet (); SqlDataAdapter adapter; SqlCommandBuilder commandBuilder; conn = new SqlConnection ("Server=localhost\\SqlExpress; Database=HealthFair;" + "Integrated Security = True"); adapter = new SqlDataAdapter ("SELECT Slot, COUNT(Slot) AS SlotCount FROM AppointmentName " + "GROUP BY Slot HAVING COUNT(Slot) > 1", conn); adapter.Fill(dataSet); commandBuilder = new SqlCommandBuilder (adapter ); adapter.Update(dataSet);
Now how do I get the data into objects so I can determin which records in Slots to cut off?
|
|
|
|
|
6
|
Other Software / Developer's Corner / Re: ASP.NET and C# webform. Need help with query to DB
|
on: July 30, 2009, 06:25:47 PM
|
|
What is count(1)? I am using SQL server and my table is as follows:
Table AppointmentName: AppID, LastName, FirstName, Email, BirthDate, Slot.
Slot gets an SelectedIndexValue from the radio button on submitClick.
On Page_Load is where I need to have the SQL statement to see how many times the value from the column "Slot" has been used.
|
|
|
|
|
7
|
Other Software / Developer's Corner / Re: <asp:RadioButton /> Determining which is selected without javascript
|
on: July 30, 2009, 06:17:09 PM
|
You have to make a radiobuttonlist as follows Formatted for HTML with the GeSHI Syntax Highlighter [ copy or print] <asp:RadioButtonList ID="RadioButtonList1" runat="server" AutoPostBack="True" RepeatColumns="3" TextAlign="Left"> <asp:ListItem Value="1">07:00AM-07:15AM</asp:ListItem> <asp:ListItem Value="2">07:15AM-07:30AM</asp:ListItem> <asp:ListItem Value="3">07:30AM-07:45AM</asp:ListItem> <asp:ListItem Value="4">07:45AM-08:00AM</asp:ListItem> </asp:RadioButtonList>
Then add some statements to make sure its working (inside submitButton_Click). radioButton is my label Formatted for C# with the GeSHI Syntax Highlighter [ copy or print] if (RadioButtonList1.SelectedIndex > -1) { radioButton.Text = "<br />you selected: " + RadioButtonList1.SelectedIndex.ToString(); } else { radioButton.Text = "Select a radio button"; }
Then attache it to the database like so: Formatted for C# with the GeSHI Syntax Highlighter [ copy or print] appNameComm = new SqlCommand ("INSERT INTO AppointmentName (LastName, FirstName, Email, BirthDate, Slot) " + "VALUES (@LastName, @FirstName, @Email, @BirthDate, @Slot)", conn); . . . appNameComm.Parameters.Add("@Slot", System.Data.SqlDbType.Int, 2); appNameComm.Parameters["@Slot"].Value = RadioButtonList1.SelectedIndex.ToString();
|
|
|
|
|
9
|
Other Software / Developer's Corner / ASP.NET and C# webform. Need help with query to DB
|
on: July 30, 2009, 03:17:53 AM
|
|
I need a way to check my database and see if a record is repeated and if it's repeated twice.
I'm making a webform that will allow the user to enter his or her personal information and select a radio button of specific times. The radio button will correspond to a SlotID in my database. When the SlotID has been used twice I need to grey out the radio button because it can no longer be selected. Any help would be nice.
|
|
|
|
|
10
|
Other Software / ASP.NET / Re: Simple form using visual web developer
|
on: July 29, 2009, 03:44:17 PM
|
|
I actually went with the ASP.NET book from sitepoint.com and have been able to complete most of my webform from that book. I would Highly recommend it to anyone starting out with visual web developer and ASP.NET.
However, I've come to another standstill. I need a way to check my database and see if a record is repeated and if it's repeated twice.
I'm making a webform that will allow the user to enter his or her personal information and select a radio button of specific times. The radio button will correspond to a SlotID in my database. When the SlotID has been used twice I need to grey out the radio button because it can no longer be selected. Any help would be nice.
|
|
|
|
|
11
|
Other Software / ASP.NET / Re: Simple form using visual web developer
|
on: July 24, 2009, 03:37:16 PM
|
|
Well in college I learned how to make databases in Access and I learned how to make webpages using HTML and script. however, I never got any classes putting them together. So, I'm sort of in the dark.
I'm going to be looking as well, but if you find something really pertinate to what i'm doing, please pot the URL.
|
|
|
|
|
12
|
Other Software / ASP.NET / Simple form using visual web developer
|
on: July 24, 2009, 02:58:22 PM
|
|
I'm trying to learn the basics and to do a project. The project requires that I have a web form which allows the user to input their name and such and hit the submit button. Upon hitting the submit button the information is sent to the database. I have a database ready to go, a datalayer but i'm unsure about sending the information. I've been able to view the table through gridview but not much else.
I've been looking for a tutorial to do just what i'm trying to do in my project but haven't got much luck. If i could just get the skinny doing something as simple as inputting a name in a textbox, pressing submit, and the string from the textbox shoing up in the appropriate field in the db table, that would be awesome and I could figure out the rest.
|
|
|
|
|
14
|
Other Software / Developer's Corner / multi answer multi choice database
|
on: March 24, 2009, 07:51:07 PM
|
|
I'm making a survey and I have to be able to allow the surveyee to check more than one option from the multiple choice answer. I've made a single answer multiple choice answer php page behind a database, but I'm not quite sure about the multi choice option.
I'm sure I can make the php part work, but i'm not sure how I'd get both answers in the database in a neat fashion.
Any thoughts?
|
|
|
|
|
17
|
Other Software / Developer's Corner / I'm trying to figure out this tutorial (phP database driven website)
|
on: March 08, 2009, 09:53:42 PM
|
http://www.devx.com/webdev/Article/27175/0/page/2Formatted for PHP with the GeSHI Syntax Highlighter [ copy or print] <?php // Connect to the database server Make sure not to use a 'blank' root password // the way that I am doing here! :) $dbconn = @mysql_connect('mysql6.000webhost.com', 'a8784371_kyle', 'xxx'); if (!$dbconn) { die('Error connecting to DB!'); } // Find the surveys db { die( '<p>Unable to locate the main database at this time.</p>' ); } // This page requires a URL parameter with the QuestionID. if(isset($_GET["QuestionID"])) $Qid = $_GET["QuestionID"]; else die("Please set a question id in the URL"); // Get the Question text corresponding to this ID $Sql = "Select * from Questions where QuestionID=" . $Qid; // The text of the Question is in Column 1 $QText = $row[1]; // Get the options for this question. $Sql2 = "Select * from Options where QuestionID=" . $Qid; // Write out the HTML for the page ?> <html> <head> <meta http-equiv="Content-Language" content="en-us"> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <title>Test 1</title> <style> <!-- .BulletText { font-family: Verdana; font-size: 8pt; text-align: left; line-height: 100%; word-spacing: 0; margin-top: 0; margin-bottom: 0 } --> </style> </head> <body> <!-- --------------------------------------------------------------- The question is going to be a HTML form. The form will be generated by this PHP script. It will be a paragraph of text containing the question followed by n radio buttons, with each being the options associated with the question. Finally, there will be a hidden button containing the Question ID (so it can be passed onto the form processor) ------------------------------------------------------------------> <form method="POST" action="process.php"> <!-- Write out the question Text --> <p><?php echo($QText)?></p> <? $nVal = 0; { if($nVal==0) // The First Option will be checked. echo("<p class='BulletText'><input type='radio' value='" . $nVal . "' checked name='Q' id='Q'>" . $optrow[2] . "</p>"); else // The Others Won't echo("<p class='BulletText'><input type='radio' value='" . $nVal . "' name='Q' id='Q'>" . $optrow[2] . "</p>"); $nVal++; } ?> <p><input type="hidden" value="<?php echo($Qid); ?>" name="QID"/></p> <p><input type="submit" value="Submit" name="B1"> <input type="reset" value="Reset" name="B2"></p> </form> </body> </html>
I view my php file in the browser using http://istem.comyr.com/survey.php (this is were the file is stored) The code is executed until the php requests the "questionid" and I get the controlled error message, "Please set a question id in the URL". By the code above I'm pretty sure that I'm getting into the database correctly. The tutorial site tells me that I should call the page using example, http://yourserver/survey.php?questionid=1. So I do http://istem.comyr.com/survey.php?questionid=1I don't know what is wrong because I'm an relatively new to php. This is how I created the my fields. Formatted for SQL with the GeSHI Syntax Highlighter [ copy or print] CREATE TABLE `answers` ( `AnswerID` int(11) NOT NULL AUTO_INCREMENT, `AnswerValue` int(11) DEFAULT '0', `AnswerIP` text, `QuestionID` int(11) DEFAULT '0', PRIMARY KEY (`AnswerID`) ) TYPE=MyISAM; CREATE TABLE `options` ( `OptionID` int(11) NOT NULL AUTO_INCREMENT, `QuestionID` int(11) DEFAULT '0', `OptionText` text, `OptionValue` int(11) DEFAULT '0', PRIMARY KEY (`OptionID`) ) TYPE=MyISAM; CREATE TABLE `questions` ( `QuestionID` int(11) NOT NULL AUTO_INCREMENT, `QuestionText` text NOT NULL, PRIMARY KEY (`QuestionID`) ) TYPE=MyISAM;
Also, I added a record in 'questions' with id being 1, and text being 'What's your favorite color'. and for options I connected each option to questionid=1. I'm pretty sure my database is correct because everything makes sense and everything is spelled the same. Please take a look and give me a few suggestions
|
|
|
|
|
19
|
Other Software / Developer's Corner / Re: two way bubble sort
|
on: September 07, 2008, 12:57:22 PM
|
Formatted for C# with the GeSHI Syntax Highlighter [ copy or print] public static void bubble( int a[] ) { boolean done = false; int temp; for( int forwardPass = 1; forwardPass < N && !done; forwardPass++ ) { done = true; for( int i = 0; i < N - forwardPass; i++ ) { if( a[ i ] > a[ i + 1 ] ) { temp = a[ i ]; a[ i ] = a[ i + 1 ]; a[ i + 1 ] = temp; done = false; } } } }
Please don't give me the answer but help walk me through it. This is the code that makes the bubble sort keep making forward passes though the array until done = true (all the values in the array are sorted in a lowest to highest value order). I am confused to hell as to how to make the sort make a forward pass and at the end make a backward pass and then forward again until all the values are in order. Basically I'm trying to come up with the best algorithm of sorting to sort in the least amount of time using a bubble sort method (the one list above).
|
|
|
|
|
20
|
Other Software / Developer's Corner / two way bubble sort
|
on: September 07, 2008, 11:23:41 AM
|
Formatted for Java with the GeSHI Syntax Highlighter [ copy or print] public static void bubble( int a[] ) { boolean done = false; int temp; for( int forwardPass = 1; forwardPass < N && !done; forwardPass++ ) { done = true; for( int i = 0; i < N - forwardPass; i++ ) { if( a[ i ] > a[ i + 1 ] ) { temp = a[ i ]; a[ i ] = a[ i + 1 ]; a[ i + 1 ] = temp; if( a[ i ] < a[ i - 1 ] ) { temp = a[ i ]; a[ i ] = a[ i - 1 ]; a[ i - 1 ] = temp; done = false; } done = false; } } } }
I'm trying to write a method that will sort some values that I've put into an array. The first "if" statement does a bubble sort forwards and I know that works. I'm trying to get the bubble sort to sort backwards after the forward pass and the 2nd "if" statement is my attempt at doing so. It seems to me that the code provided would work accordingly but it doesn't. I tried commenting out the first "if" statement and the program stops working at the 2nd "if" statement. However, if nothing is commented out then the program sorts like it should so maybe I'm testing it wrong.
|
|
|
|
|
21
|
Other Software / Developer's Corner / Re: C# Palindrom Recursive Program
|
on: April 19, 2007, 03:43:42 PM
|
This is the Palindrom in non recursive format but I need to put it in recursive format. From my understanding I should put most of this code in a method, probably in another class, then have the main method call upon it every time the system loops ========================================================== Formatted for C# with the GeSHI Syntax Highlighter [ copy or print] namespace RecursivePalindromeTester { class Palindrome { String str, another = "y"; int left, right; while (another.ToUpper() == "Y") { Console.Out.WriteLine("Enter a potential Palindrome:"); str = Console.In.ReadLine(); left = 0; right = str.Length - 1; while (str[left] == str[right] && left < right) { left++; right--; } Console.Out.WriteLine(); if (left < right) Console.Out.WriteLine("String is Not a Palindrome."); else Console.Out.WriteLine("String is a Palindrome."); Console.Out.WriteLine(); Console.Out.Write("Test another PalindromTester (Y/N)? "); another = Console.In.ReadLine(); } }
|
|
|
|
|
22
|
Other Software / Developer's Corner / C# Palindrom Recursive Program
|
on: April 17, 2007, 09:38:11 PM
|
|
I have to make a program using C# that makes a PalindromeTester using Recursive methods. I can make the program using normal methods i.e. while statements and nested if statements. I can't figure it out even after doing a lot of research and while looking at sudocode from someone writing it in java. Could someone help. I don't necessarily want someone to do the work for me but help me think it through using the c# language. I would talk to my Teacher about it but she can't bring herself to coming to my level. People with Ph.D's shouldn't be allowed to teach low level college classes.
|
|
|
|
|