Click here to Skip to main content
15,899,026 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: Encryption / Decryption Pin
jkirkerx24-Nov-15 12:23
professionaljkirkerx24-Nov-15 12:23 
QuestionMSchart isn't show completely Pin
Member 1154563919-Nov-15 0:19
Member 1154563919-Nov-15 0:19 
AnswerRe: MSchart isn't show completely Pin
ZurdoDev23-Nov-15 3:00
professionalZurdoDev23-Nov-15 3:00 
QuestionMVC Forum ? Pin
John C Rayan17-Nov-15 1:20
professionalJohn C Rayan17-Nov-15 1:20 
AnswerRe: MVC Forum ? Pin
ZurdoDev23-Nov-15 3:00
professionalZurdoDev23-Nov-15 3:00 
GeneralRe: MVC Forum ? Pin
John C Rayan23-Nov-15 22:26
professionalJohn C Rayan23-Nov-15 22:26 
QuestionDetailsview InsertItem Pin
tiwal15-Nov-15 23:08
tiwal15-Nov-15 23:08 
AnswerRe: Detailsview InsertItem Pin
tiwal15-Nov-15 23:20
tiwal15-Nov-15 23:20 
To make things clearer here is my marlup :

ASP.NET
<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Insert.aspx.cs" Inherits="DBManagerWebForm.Insert" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
    <asp:DetailsView ID="DetailsView1" runat="server" DefaultMode="Insert" Height="50px" Width="125px" AutoGenerateInsertButton="True" OnItemInserting="DetailsView1_ItemInserting" OnItemUpdating="DetailsView1_ItemUpdating">
    </asp:DetailsView>
    <%--<asp:Button ID="btnOk" runat="server" OnClick="btnOk_Click" Text="Ok" />
    <asp:Button ID="btnReset" runat="server" OnClick="btnReset_Click" Text="Reset" />--%>
    <asp:Button ID="btnCancel" runat="server" OnClick="btnCancel_Click" Text="Go Back" />
    <br />
    <asp:TextBox ID="txtError" runat="server" ReadOnly="True" TextMode="MultiLine" Width="411px"></asp:TextBox>
</asp:Content>



and this is the codebehind :

C#
protected void DetailsView1_ItemInserting(object sender, DetailsViewInsertEventArgs e)
       {
           int i;
           SqlDbType T;
           try
           {
                string Cmd = "INSERT INTO " + TABLE + " (";
               IEnumerator En =  e.Values.Keys.GetEnumerator();
               En.Reset();
               for (i = 0; i < e.Values.Count - 1; i++)
               {
                   En.MoveNext();
                   Cmd += En.Current.ToString() + ",";
               }
               En.MoveNext();
               Cmd += En.Current.ToString() + ") VALUES (";
               string val;


               En.Reset();
               for (i = 0; i < e.Values.Count - 1; i++)
               {
                   En.MoveNext();
                   T = Util.GetSqlType(DT.Columns[i].DataType);
                   val = e.Values[En.Current] == null ? "" : e.Values[En.Current].ToString();
                   if (T == SqlDbType.NVarChar)
                       Cmd += "'" + val + "',";
                   else
                       Cmd += val + ",";
               }
               En.MoveNext();
               T = Util.GetSqlType(DT.Columns[i].DataType);
               val = e.Values[En.Current] == null ? "" : e.Values[En.Current].ToString();
               if (T == SqlDbType.NVarChar)
                   Cmd += "'" + val + "')";
               else
                   Cmd += val + ")";


 string ConnStr = WebConfigurationManager.ConnectionStrings[CONNECTION].ConnectionString;

               SqlConnection Conn = new SqlConnection(ConnStr);
               Conn.Open();
               SqlCommand Comm = new SqlCommand(Cmd, Conn);
               int r = Comm.ExecuteNonQuery();
               Conn.Close();

               // Response.Redirect("~/modifica.aspx");
               Server.Transfer("~/modifica.aspx");
           }
           catch (Exception ex)
           {
               txtError.Text = "Errore :" + ex.Message;
           }
       }

SuggestionRe: Detailsview InsertItem Pin
Richard Deeming16-Nov-15 2:56
mveRichard Deeming16-Nov-15 2:56 
QuestionASP.NET Pin
Member 1214037915-Nov-15 4:09
Member 1214037915-Nov-15 4:09 
AnswerRe: ASP.NET Pin
Afzaal Ahmad Zeeshan15-Nov-15 23:57
professionalAfzaal Ahmad Zeeshan15-Nov-15 23:57 
AnswerRe: ASP.NET Pin
ZurdoDev16-Nov-15 2:20
professionalZurdoDev16-Nov-15 2:20 
Questionasp.net Pin
Member 1214037915-Nov-15 3:51
Member 1214037915-Nov-15 3:51 
AnswerRe: asp.net Pin
Afzaal Ahmad Zeeshan15-Nov-15 23:58
professionalAfzaal Ahmad Zeeshan15-Nov-15 23:58 
AnswerRe: asp.net Pin
ZurdoDev16-Nov-15 2:21
professionalZurdoDev16-Nov-15 2:21 
QuestionGridview with full-screen editing question Pin
Member 1044208512-Nov-15 7:53
Member 1044208512-Nov-15 7:53 
AnswerRe: Gridview with full-screen editing question Pin
Mathi Mani12-Nov-15 8:18
Mathi Mani12-Nov-15 8:18 
GeneralRe: Gridview with full-screen editing question Pin
Member 1044208512-Nov-15 9:08
Member 1044208512-Nov-15 9:08 
QuestionHelp with a connection string Pin
Member 121243549-Nov-15 13:50
Member 121243549-Nov-15 13:50 
AnswerRe: Help with a connection string Pin
Wombaticus10-Nov-15 1:09
Wombaticus10-Nov-15 1:09 
AnswerRe: Help with a connection string Pin
Richard Deeming10-Nov-15 1:21
mveRichard Deeming10-Nov-15 1:21 
GeneralRe: Help with a connection string Pin
Member 1212435410-Nov-15 12:28
Member 1212435410-Nov-15 12:28 
GeneralRe: Help with a connection string Pin
Richard Deeming11-Nov-15 1:54
mveRichard Deeming11-Nov-15 1:54 
GeneralRe: Help with a connection string Pin
Member 1212435411-Nov-15 11:59
Member 1212435411-Nov-15 11:59 
QuestionJquery Ajax method call with asp.net static webmethods Pin
ganesh.dks8-Nov-15 20:31
ganesh.dks8-Nov-15 20:31 

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.