Click here to Skip to main content
15,917,793 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: Links in dynamic datagrid Pin
nachiket0718-Feb-10 7:58
nachiket0718-Feb-10 7:58 
GeneralRe: Links in dynamic datagrid Pin
nachiket0718-Feb-10 12:15
nachiket0718-Feb-10 12:15 
GeneralRe: Links in dynamic datagrid Pin
Dinesh Mani18-Feb-10 18:11
Dinesh Mani18-Feb-10 18:11 
GeneralRe: Links in dynamic datagrid Pin
nachiket0719-Feb-10 19:29
nachiket0719-Feb-10 19:29 
QuestionAn existing connection was forcibly closed by the remote host Pin
adeeeb17-Feb-10 10:17
adeeeb17-Feb-10 10:17 
Questionhow to store first page's primary key key value in second pages foreign key attribute. Pin
jattscorpion17-Feb-10 7:24
jattscorpion17-Feb-10 7:24 
AnswerRe: how to store first page's primary key key value in second pages foreign key attribute. Pin
Abhishek Sur17-Feb-10 9:48
professionalAbhishek Sur17-Feb-10 9:48 
GeneralRe: how to store first page's primary key key value in second pages foreign key attribute. Pin
jattscorpion17-Feb-10 12:31
jattscorpion17-Feb-10 12:31 
QuestionHow to set the sender address (Field From) usin MAPI Pin
nahelpa17-Feb-10 6:41
nahelpa17-Feb-10 6:41 
QuestionEvent on asp:calendar Pin
_ASPAle_17-Feb-10 6:06
_ASPAle_17-Feb-10 6:06 
AnswerRe: Event on asp:calendar Pin
Brij17-Feb-10 19:22
mentorBrij17-Feb-10 19:22 
GeneralRe: Event on asp:calendar Pin
_ASPAle_18-Feb-10 0:04
_ASPAle_18-Feb-10 0:04 
QuestionNeed some assistance with adding a datarow to a datatable Pin
Will Talley17-Feb-10 5:34
Will Talley17-Feb-10 5:34 
AnswerRe: Need some assistance with adding a datarow to a datatable Pin
Abhishek Sur17-Feb-10 5:59
professionalAbhishek Sur17-Feb-10 5:59 
GeneralRe: Need some assistance with adding a datarow to a datatable Pin
Will Talley18-Feb-10 2:38
Will Talley18-Feb-10 2:38 
AnswerRe: Need some assistance with adding a datarow to a datatable Solved! Pin
Will Talley18-Feb-10 4:58
Will Talley18-Feb-10 4:58 
Nevermind, I solved it. My problem was that whenever I did an Ajax postback, the entire table would be lost, not emptied. So all I had to do was copy it to a viewstate, and then reload it from the viewstate. It goes as follows:

//First I added these two lines to a function inside my load event, and the function only ran if the page wasn't a postback:
NewHouseholdDatatable = new DataTable();
                AddEmptyColumnsToDatatable(NewHouseholdDatatable);


Then I changed my adding code to the following:

protected void AddNewFamilyMemberToDatatable(string SSN, string First, string Last, string DOB, string AdultChild, string Gender, bool Head, String ConsentForm, string Ethnicity)
       {
         //If there was something in the viewstate, I loaded it from memory.  Otherwise, I simply recreated the table.
               if (ViewState["NewHouseholdDatatable"] != null)
               {
                   NewHouseholdDatatable = (DataTable)ViewState["NewHouseholdDatatable"];
                   //  FamilyWarning.Text += "<br/>There are now" + NewHouseholdDatatable.Rows.Count.ToString() + " rows in the table before adding empty columns and after getting changes";
                   AddEmptyColumnsToDatatable(NewHouseholdDatatable);//This is used to add empty columns to the datatable in case they aren't there already, otherwise I'd get a "does not contain column _ exception.
               }
               else
               {
                   NewHouseholdDatatable = new DataTable();
                   AddEmptyColumnsToDatatable(NewHouseholdDatatable);
               }
               FamilyWarning.Text += "<br/>There are now" + NewHouseholdDatatable.Rows.Count.ToString() + " rows in the table after adding empty columsn";

               FamilyWarning.Text += "<br/>There are now" + NewHouseholdDatatable.Rows.Count.ToString() + " rows in the table after assigning datasource";

               //NewHouseholdDatable is the name of the datatable I'm using, and it's set up in the page's Init event.
               DataRow Row = NewHouseholdDatatable.NewRow();
               //This stuff simply sets the values to the new row
               if (Head)
               {
                   Row["HeadOfHousehold"] = true;
               }
               else
               {
                   Row["HeadOfHousehold"] = false;

               }
               Row["Firstname"] = First;
               Row["DOB"] = DOB;
               Row["Lastname"] = Last;
               Row["SSN"] = SSN;
               Row["AdultChild"] = AdultChild;
               Row["MaleFemale"] = Gender;

               if (ConsentForm == "1")
               { Row["ConsentForm"] = true; }
               else
               { Row["ConsentForm"] = false; }
               Row["Ethnicity"] = Ethnicity;
               if (!CheckIsDate(DOB))
               {
                   Row["Age"] = 0;
                   Row["DateOfBirth"] = "Unknown, please edit and enter proper data";
               }
               else
               {
                   Row["Age"] = GetAge(DateTime.Parse(DOB));
                   DateTime DateAndTimeOfBirth = Convert.ToDateTime(DOB);
                   Row["DateOfBirth"] = DateAndTimeOfBirth.ToShortDateString();
               }
               try
               {
                   FamilyWarning.Text += "<br/>There are " + NewHouseholdDatatable.Rows.Count.ToString() + " rows in the table before adding";
                   NewHouseholdDatatable.Rows.Add(Row);


                   FamilyWarning.Text += "<br/>There are now" + NewHouseholdDatatable.Rows.Count.ToString() + " rows in the table after accepting changes";
                   ClearForm();
                   //FamilyMembers is the name of the gridview that I'm binding it to.,
                   ViewState["NewHouseholdDatatable"] = NewHouseholdDatatable;
                   FamilyMembers.DataSource = NewHouseholdDatatable;
                   FamilyMembers.DataBind();
                   FamilyWarning.Text += "<br/>There are now" + NewHouseholdDatatable.Rows.Count.ToString() + " rows in the table after databinding";
                   // FamilyWarning.Text = Row["Firstname"] + " " + Row["Lastname"] + " successfully added.  There are " + NewHouseholdDatatable.Rows.Count.ToString() + " rows in the table.";

               }
               catch (Exception ex)
               {
                   FamilyWarning.Text += "<br/>Unable to add this person to the table, " + ex.Message;
               }


       }

Questionbinding data to a data list Pin
arindam201017-Feb-10 5:18
arindam201017-Feb-10 5:18 
AnswerRe: binding data to a data list Pin
Abhishek Sur17-Feb-10 6:02
professionalAbhishek Sur17-Feb-10 6:02 
GeneralRe: binding data to a data list Pin
arindam201017-Feb-10 6:56
arindam201017-Feb-10 6:56 
GeneralRe: binding data to a data list Pin
Abhishek Sur17-Feb-10 9:44
professionalAbhishek Sur17-Feb-10 9:44 
AnswerRe: binding data to a data list Pin
Anurag Gandhi17-Feb-10 6:37
professionalAnurag Gandhi17-Feb-10 6:37 
GeneralRe: binding data to a data list Pin
arindam201017-Feb-10 6:54
arindam201017-Feb-10 6:54 
GeneralRe: binding data to a data list Pin
Anurag Gandhi17-Feb-10 15:52
professionalAnurag Gandhi17-Feb-10 15:52 
QuestionWeb Service Protection with Client Certificates Pin
captainone17-Feb-10 3:55
captainone17-Feb-10 3:55 
AnswerRe: Web Service Protection with Client Certificates Pin
Ennis Ray Lynch, Jr.17-Feb-10 5:19
Ennis Ray Lynch, Jr.17-Feb-10 5:19 

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.