Click here to Skip to main content
15,920,030 members
Home / Discussions / C#
   

C#

 
AnswerRe: C# Pin
OriginalGriff4-Sep-16 19:57
mveOriginalGriff4-Sep-16 19:57 
AnswerGreat subject Pin
Luc Pattyn5-Sep-16 3:42
sitebuilderLuc Pattyn5-Sep-16 3:42 
GeneralRe: Great subject Pin
Pete O'Hanlon5-Sep-16 4:06
mvePete O'Hanlon5-Sep-16 4:06 
AnswerRe: C# Pin
#realJSOP6-Sep-16 1:36
professional#realJSOP6-Sep-16 1:36 
Questionjson attribute for ienumerable items Pin
Raghavendra.Kodimala2-Sep-16 23:05
professionalRaghavendra.Kodimala2-Sep-16 23:05 
AnswerRe: json attribute for ienumerable items Pin
Richard MacCutchan3-Sep-16 0:33
mveRichard MacCutchan3-Sep-16 0:33 
AnswerRe: json attribute for ienumerable items Pin
Richard Deeming5-Sep-16 2:11
mveRichard Deeming5-Sep-16 2:11 
Questionshows the insert and read only mode of form view main page dynamically doesn`t work in insert Pin
Member 126153702-Sep-16 20:28
Member 126153702-Sep-16 20:28 
i add auser control which has aformview control to main page dynamically with c# code ,but i set in the page load of the main page the form view with read only mode to bind the data and when i press add section in main page the form view become in insert mode but when i click insert it doesn`t do insert because it make post pack and load the page load which set the form view mode to read only to bind the data which come from the database

the problem is how to set the default mode of form view to insert in the same page which i called the control dynamically with read only mode

find the code html of the user contrl form


ASP.NET
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="skills.ascx.cs" Inherits="JobSeeker_skills" %>


<asp:UpdatePanel ID="UpdatePanel1" runat="server"  UpdateMode="Conditional" >
        <ContentTemplate>
    <asp:FormView id="Formviewskills" runat ="server" style="width:100%" DataSourceID="FormViewskillsSDS"
   umbDebugShowTrace="true"     DataKeyNames="SkillsID" OnItemCreated="Formviewskills_ItemCreated"  > 
         <EditItemTemplate>
    
          <table style="width:100%">    
                 <tr>
              <td class="col-md-6">  
               <asp:label  class="link_sgray" id="FirstName" runat="server"  >Skills: </asp:label>
                  <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="Skills" 
                        Display="Dynamic" ErrorMessage="*"></asp:RequiredFieldValidator>
              <br />
			
                     <asp:Textbox style="width:100%" id="Skills" class="form-control" runat="server" 
                               Text='<%# Bind("Skills") %>' >
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                   </asp:Textbox>
                                    
               
                              
                  </td>           
                        
			
                      </tr>
              <tr>
                    <tr>
                          <td class="col-md-6">
                <asp:label class="link_sgray" id="Label1" runat="server"  >Proficiency: </asp:label>
                  <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ControlToValidate="Proficiency"
                        Display="Dynamic" ErrorMessage="*"></asp:RequiredFieldValidator>
              <br />
		
                           <asp:DropDownList style="width:100%" id="Proficiency" CssClass="dropdown" runat="server"  selectedvalue='<%# Bind("Proficiency") %>'
                                DataSourceID="ProficiencyDDL"  DataTextField="Value"  DataValueField="ID">
                                   </asp:DropDownList>
                                    
                        
				      
			</td>
                     	<td class="col-md-6">
                <asp:label class="link_sgray" id="Label8" runat="server"  >Years of Experience:&nbsp;  </asp:label>
                  <asp:RequiredFieldValidator ID="RequiredFieldValidator9" runat="server" ControlToValidate="YearsofExperienceSkills"
                        Display="Dynamic" ErrorMessage="*"></asp:RequiredFieldValidator>
              <br />
		
                           <asp:DropDownList style="width:100%" id="YearsofExperienceSkills" CssClass="dropdown" runat="server" selectedvalue='<%# Bind("YearsofExperienceSkills") %>'
                                DataSourceID="YearsofExperienceSkillsDDL" DataTextField="Value" DataValueField="ID">
                                   </asp:DropDownList>
                                    
                        
				      
			</td>

                 <%-- <td class="col-md-6" colspan="2">
                  <table>
                    
                 <td "col-md-4" width="35%">  
               <asp:label  class="link_sgray" id="Label2" runat="server"  >Last Used: </asp:label>
                  <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="LastUsed" 
                        Display="Dynamic" ErrorMessage="*"></asp:RequiredFieldValidator>
              <br />
					<asp:DropDownList ID="LastUsed" runat="server" CssClass="dropdown" DataSourceID="LastUsedDDL"  DataTextField="Value" selectedvalue='<%# Bind("LastUsed") %>'
                         DataValueField="ID" Width="100%"></asp:DropDownList>
                                    </td> 
                     </tr>
                  </table>
                      </td>--%>
              </tr>
              <tr>

             <td colspan="2">
                           <asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True"  CommandName="Update" Text="Update" CssClass="btn-primary" />
           &nbsp;<asp:LinkButton ID="UpdateCancelButton" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancel" CssClass="btn-primary"/>
                      </td>  
                  </tr>
               
                
     </table>
        
        </EditItemTemplate>

        <InsertItemTemplate>
           <table style="width:100%">    
                 <tr>
              <td class="col-md-6">  
               <asp:label  class="link_sgray" id="Skillslbl" runat="server"  >Skills: </asp:label>
                 <%-- <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="Skills" 
                        Display="Dynamic" ErrorMessage="*"></asp:RequiredFieldValidator>--%>
              <br />
			
                     <asp:Textbox style="width:100%" id="Skills" class="form-control" runat="server" 
                               Text='<%# Bind("Skills") %>' ></asp:Textbox>
                                    
               
                              
                  </td>           
                        
			
                      </tr>
              <tr>
                          <td class="col-md-6">
                <asp:label class="link_sgray" id="Label1" runat="server"  >Proficiency: </asp:label>
                  <%--<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ControlToValidate="Proficiency"
                        Display="Dynamic" ErrorMessage="*"></asp:RequiredFieldValidator>--%>
              <br />
		
                           <asp:DropDownList style="width:100%" id="Proficiency" CssClass="dropdown" runat="server" selectedvalue='<%# Bind("Proficiency") %>'
                                DataSourceID="ProficiencyDDL" DataTextField="Value" DataValueField="ID">
                                   </asp:DropDownList>
                                    
                        
				      
			</td>
                     	<td class="col-md-6">
                <asp:label class="link_sgray" id="Label8" runat="server"  >Years of Experience:&nbsp;  </asp:label>
                <%--  <asp:RequiredFieldValidator ID="RequiredFieldValidator9" runat="server" ControlToValidate="YearsofExperienceSkills"
                        Display="Dynamic" ErrorMessage="*"></asp:RequiredFieldValidator>--%>
              <br />
		
                           <asp:DropDownList style="width:100%" id="YearsofExperienceSkills" CssClass="dropdown" runat="server" selectedvalue='<%# Bind("YearsofExperienceSkills") %>'
                                DataSourceID="YearsofExperienceSkillsDDL" DataTextField="Value" DataValueField="ID">
                                   </asp:DropDownList>
                                    
                        
				      
			</td>

                 
              </tr>
              <tr>

             <td>
                           <asp:Button ID="insertButton" runat="server" CommandName="Insert"
                              Text="Insert" CssClass="btn-primary"   ></asp:Button>
           &nbsp;<asp:Button ID="insertCancelButton" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancel" CssClass="btn-primary" ></asp:Button>
                     </td>
                  </tr>
               
                
     </table>
               
           
        </InsertItemTemplate>
        <ItemTemplate>
            <table style="width:100%">    
                 <tr>
              <td class="col-md-6">  
               <asp:label  class="link_sgray" id="FirstName" runat="server"  >Skills: </asp:label>
                  
              <br />
			
                    <asp:Textbox style="width:100%" id="Skills" class="form-control" runat="server"  Enabled="false"
                               Text='<%# Eval("Skills") %>'></asp:Textbox>
                                    
               
                              
                  </td>           
                        
			
                      </tr>
              <tr>
                          <td class="col-md-6">
                <asp:label class="link_sgray" id="Label1" runat="server"  >Proficiency: </asp:label>
                  <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ControlToValidate="Proficiency" 
                        Display="Dynamic" ErrorMessage="*"></asp:RequiredFieldValidator>
              <br />
		
                           <asp:DropDownList style="width:100%" id="Proficiency" CssClass="dropdown" runat="server" Enabled="false" selectedvalue='<%# Eval("Proficiency") %>'
                                DataSourceID="ProficiencyDDL" DataTextField="Value" DataValueField="ID">
                                   </asp:DropDownList>
                                    
                        
				      
			</td>
                     	<td class="col-md-6">
                <asp:label class="link_sgray" id="Label8" runat="server"  >Years of Experience:&nbsp;  </asp:label>
                  <asp:RequiredFieldValidator ID="RequiredFieldValidator9" runat="server" ControlToValidate="YearsofExperienceSkills"
                        Display="Dynamic" ErrorMessage="*"></asp:RequiredFieldValidator>
              <br />
		
                           <asp:DropDownList style="width:100%" id="YearsofExperienceSkills" CssClass="dropdown" Enabled="false" runat="server" selectedvalue='<%# Eval("YearsofExperienceSkills") %>'
                                DataSourceID="YearsofExperienceSkillsDDL" DataTextField="Value" DataValueField="ID">
                                   </asp:DropDownList>
                                    
                        
				      
			</td>

                 <%-- <td class="col-md-6" colspan="2">
                  <table>
                    
                 <td "col-md-4" width="35%">  
               <asp:label  class="link_sgray" id="Label2" runat="server"  >Last Used: </asp:label>
                  <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="LastUsed" 
                        Display="Dynamic" ErrorMessage="*"></asp:RequiredFieldValidator>
              <br />
					<asp:DropDownList ID="LastUsed" runat="server" CssClass="dropdown" DataSourceID="LastUsedDDL"  DataTextField="Value" selectedvalue='<%# Bind("LastUsed") %>'
                         DataValueField="ID" Width="100%"></asp:DropDownList>
                                    </td> 
                     </tr>
                  </table>
                      </td>--%>
              </tr>
              <tr>

             <td>
                           <asp:LinkButton ID="EditButton" runat="server" CausesValidation="True"  CommandName="Edit" Text="Edit" CssClass="btn-primary" />
           &nbsp;<asp:LinkButton ID="DeletelButton" runat="server" CausesValidation="False" CommandName="Delete" Text="Delete" CssClass="btn-primary"/>
                       </td>
                  </tr>
               
                
     </table>

        </ItemTemplate>
   
        
         </asp:FormView>
            </ContentTemplate>
</asp:UpdatePanel>
            

  <asp:SqlDataSource ID="ProficiencyDDl" runat="server" ConnectionString="<%$ ConnectionStrings:crms%>" 
            SelectCommand="SELECT [ID]
      ,[Value]
  FROM [dbo].[StringMap]
  where [AttributeName]='Proficiency' "> </asp:SqlDataSource>
 <asp:SqlDataSource ID="YearsofExperienceSkillsDDl" runat="server" ConnectionString="<%$ ConnectionStrings:crms%>" 
            SelectCommand="SELECT [ID]
      ,[Value]
  FROM [dbo].[StringMap]
  where [AttributeName]='Years of Experience Skills' "> </asp:SqlDataSource>
<%-- <asp:SqlDataSource ID="LastUsedDDL" runat="server" ConnectionString="<%$ ConnectionStrings:crms%>" 
            SelectCommand="SELECT [ID]
      ,[Value]
  FROM [dbo].[StringMap]
  where [AttributeName]='Last Used' "> </asp:SqlDataSource>--%>


<asp:sqldatasource id ="FormViewskillsSDS" runat="Server" ConnectionString="<%$ ConnectionStrings:crms%>"  
     SelectCommand=" 
SELECT SkillsID,
	 [Skills] ,
     [Proficiency] ,
     [YearsofExperienceSkills] 
   
     FROM Skills
inner join StringMap SMSP on SMSP.ID= Skills.Proficiency
  and SMSP.AttributeName='Proficiency'
   inner join StringMap SMYOES on SMYOES.ID= Skills.YearsofExperienceSkills
  and SMYOES.AttributeName='Years of Experience Skills'

  where ApplicantID=@ApplicantID  and
 SkillsID= @SkillsID
  " 
    InsertCommand="Insert into [Skills] ( Skills ,
     Proficiency ,
    YearsofExperienceSkills 
   , ApplicantID )  VALUES   ( @Skills, @Proficiency , @YearsofExperienceSkills  , @ApplicantID); select @SkillsID = SCOPE_IDENTITY() "
   
     DeleteCommand="DELETE FROM [Skills] WHERE  [SkillsID] = @SkillsID"
    UpdateCommand="UPDATE Skills
   SET
      Skills= @Skills
     ,Proficiency= @Proficiency
   , YearsofExperienceSkills= @YearsofExperienceSkills
  WHERE ApplicantID = @ApplicantID and
 SkillsID= @SkillsID">

    <SelectParameters>

        <asp:SessionParameter Name="ApplicantID" Type="Int32"  SessionField="ApplicantID"  />
          <asp:Parameter Name="SkillsID" Type="Int32"    />
    </SelectParameters>
  <InsertParameters>
      
         <asp:ControlParameter Name="Skills"  ControlID="Formviewskills$Skills" Type="string" PropertyName="Text"  />
       <asp:ControlParameter Name="Proficiency"  ControlID="Formviewskills$Proficiency" Type="int32" PropertyName="SelectedValue"  />
       <asp:ControlParameter Name="YearsofExperienceSkills"  ControlID="Formviewskills$YearsofExperienceSkills" Type="int32" PropertyName="SelectedValue" />
      <asp:SessionParameter Name="ApplicantID" Type="Int32"  SessionField="ApplicantID"  />
       <asp:parameter Direction="Output" Name="SkillsID" Type="Int32"  />
     </InsertParameters>


    <DeleteParameters>
        <asp:SessionParameter Name="SkillsID" Type="Int32" SessionField="SkillsID"  />
    </DeleteParameters>
    <UpdateParameters>

       <asp:ControlParameter Name="Skills"  ControlID="Formviewskills$Skills" Type="String" PropertyName="text"/>
       <asp:ControlParameter Name="Proficiency"  ControlID="Formviewskills$Proficiency" Type="int32" PropertyName="SelectedValue"  />
       <asp:ControlParameter Name="YearsofExperienceSkills"  ControlID="Formviewskills$YearsofExperienceSkills" Type="int32" PropertyName="SelectedValue" />
    
       <asp:SessionParameter Name="ApplicantID" Type="Int32"  SessionField="ApplicantID"  />
    </UpdateParameters>

</asp:sqldatasource>







and the dynamically code add in the page load of main page is

C#
///////Skills Section ////////////
      Session["FormMode"] = false;
      da = new SqlDataAdapter("select SkillsID from Skills Where ApplicantID='" + ApplicantID + "'", con);
      con.Open();
      ds = new DataSet();
      da.Fill(ds, "Jobs");
      DataTable SkillsTable = ds.Tables[0];
      if (SkillsTable.Rows.Count > 0)
      {
          int i = 1;
          foreach (DataRow row in SkillsTable.Rows)
          {

              DataColumn col = SkillsTable.Columns["SkillsID"];
              Session["SkillsID"] = row[col].ToString();

              HtmlGenericControl DivSkills = new HtmlGenericControl("div");
              DivSkills.Attributes.Add("class", "class=panel - body");
              DivSkills.Attributes.Add("id", (i).ToString());
              Skillspnl.Controls.Add(DivSkills);
              System.Web.UI.UserControl uc3 = (System.Web.UI.UserControl)Page.LoadControl("~/JobSeeker/skills.ascx");
              FormView SkillsFV = uc3.FindControl("Formviewskills") as FormView;
             SkillsFV.DefaultMode = FormViewMode.readonly;
             SqlDataSource SqlSkills = uc3.FindControl("FormViewskillsSDS") as SqlDataSource;
              SqlSkills.SelectParameters["SkillsID"].DefaultValue = row[col].ToString();
              SqlSkills.DataBind();
              DivSkills.Controls.Add(uc3);
              i++;
          }
      }

SuggestionRe: shows the insert and read only mode of form view main page dynamically doesn`t work in insert Pin
Richard Deeming5-Sep-16 2:10
mveRichard Deeming5-Sep-16 2:10 
QuestionHow to Add Assembly Reference in VS 2012 Pin
Member 122888402-Sep-16 16:06
Member 122888402-Sep-16 16:06 
AnswerRe: How to Add Assembly Reference in VS 2012 Pin
Richard Andrew x642-Sep-16 18:10
professionalRichard Andrew x642-Sep-16 18:10 
GeneralMessage Closed Pin
2-Sep-16 19:31
Member 122888402-Sep-16 19:31 
GeneralRe: How to Add Assembly Reference in VS 2012 Pin
Richard Andrew x643-Sep-16 3:33
professionalRichard Andrew x643-Sep-16 3:33 
QuestionMessage Removed Pin
2-Sep-16 8:22
Tej_dev2-Sep-16 8:22 
QuestionSQL1159 Initialization error with DB2 .NET Data Provider, reason code 7 Pin
Tej_dev2-Sep-16 8:02
Tej_dev2-Sep-16 8:02 
AnswerRe: SQL1159 Initialization error with DB2 .NET Data Provider, reason code 7 Pin
NotPolitcallyCorrect2-Sep-16 8:15
NotPolitcallyCorrect2-Sep-16 8:15 
AnswerRe: SQL1159 Initialization error with DB2 .NET Data Provider, reason code 7 Pin
Dave Kreskowiak2-Sep-16 9:17
mveDave Kreskowiak2-Sep-16 9:17 
GeneralRe: SQL1159 Initialization error with DB2 .NET Data Provider, reason code 7 Pin
Tej_dev6-Sep-16 6:47
Tej_dev6-Sep-16 6:47 
GeneralRe: SQL1159 Initialization error with DB2 .NET Data Provider, reason code 7 Pin
Dave Kreskowiak6-Sep-16 9:31
mveDave Kreskowiak6-Sep-16 9:31 
QuestionWhat kind of relation is created with virtual keyword in EF Pin
Tridip Bhattacharjee2-Sep-16 2:46
professionalTridip Bhattacharjee2-Sep-16 2:46 
AnswerRe: What kind of relation is created with virtual keyword in EF Pin
Pete O'Hanlon2-Sep-16 3:10
mvePete O'Hanlon2-Sep-16 3:10 
QuestionOverride properties in derived classes - some have fixed value, some do not Pin
amaturi1-Sep-16 22:32
amaturi1-Sep-16 22:32 
AnswerRe: Override properties in derived classes - some have fixed value, some do not Pin
Pete O'Hanlon1-Sep-16 22:57
mvePete O'Hanlon1-Sep-16 22:57 
AnswerRe: Override properties in derived classes - some have fixed value, some do not PinPopular
OriginalGriff1-Sep-16 23:13
mveOriginalGriff1-Sep-16 23:13 
GeneralRe: Override properties in derived classes - some have fixed value, some do not Pin
BillWoodruff2-Sep-16 1:49
professionalBillWoodruff2-Sep-16 1:49 

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.