Click here to Skip to main content
15,888,454 members
Home / Discussions / ASP.NET
   

ASP.NET

 
Questionhow to access the last modified time of the blob uploaded Pin
Trilok M Chowdary25-Dec-13 0:24
professionalTrilok M Chowdary25-Dec-13 0:24 
QuestionRe: how to access the last modified time of the blob uploaded Pin
ZurdoDev27-Dec-13 10:54
professionalZurdoDev27-Dec-13 10:54 
QuestionSession state handling in asp.net Pin
Otekpo Emmanuel24-Dec-13 2:39
Otekpo Emmanuel24-Dec-13 2:39 
AnswerRe: Session state handling in asp.net Pin
thatraja24-Dec-13 3:06
professionalthatraja24-Dec-13 3:06 
GeneralSolved: Session state handling in asp.net Pin
Otekpo Emmanuel24-Dec-13 6:00
Otekpo Emmanuel24-Dec-13 6:00 
JokeRe: Solved: Session state handling in asp.net Pin
thatraja25-Dec-13 22:49
professionalthatraja25-Dec-13 22:49 
QuestionAsp.net datalist control Pin
Otekpo Emmanuel24-Dec-13 0:44
Otekpo Emmanuel24-Dec-13 0:44 
AnswerRe: Asp.net datalist control Pin
joginder-banger25-Dec-13 15:12
professionaljoginder-banger25-Dec-13 15:12 
I here mention a complete code below in Data List Add,Remove and Update.
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;

public partial class mytesting : System.Web.UI.Page
{
   
        protected void Page_Load(object sender, EventArgs e)
        {

            if (!IsPostBack)
            {
                GetData();
            }
        }
        private void GetData()
        {

            SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=jogi;Integrated Security=True");

            try
            {

                con.Open();
                SqlCommand cmd = new SqlCommand("select * from jogi2", con);
                SqlDataAdapter da = new SqlDataAdapter(cmd);
                DataSet ds = new DataSet();
                da.Fill(ds);
                DataList1.DataSource = ds.Tables[0];
                DataList1.DataBind();
            }
            finally
            {
                con.Close();
            }
        }
        protected void DataList1_EditCommand(object source, DataListCommandEventArgs e)
        {
            DataList1.EditItemIndex = e.Item.ItemIndex;
            GetData();
        }
        protected void DataList1_CancelCommand(object source, DataListCommandEventArgs e)
        {
            DataList1.EditItemIndex = -1;
            GetData();
        }
        protected void DataList1_UpdateCommand(object source, DataListCommandEventArgs e)
        {
            String id = ((Label)e.Item.FindControl("Label3")).Text;
            TextBox role = (TextBox)e.Item.FindControl("TextBox1");
            TextBox password = (TextBox)e.Item.FindControl("TextBox3");
            SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=jogi;Integrated Security=True");
            con.Open();
            SqlCommand cmd = new SqlCommand("update jogi2 set role='" + role.Text + "',password='" + password.Text + "'where id ='" + id + "'", con);
            int i = cmd.ExecuteNonQuery();
            if (i > 0)
            {
                Label4.Text = "Recard Updated successfully....";
                GetData();
            }
        }
        protected void DataList1_DeleteCommand(object source, DataListCommandEventArgs e)
        {
            String id = ((Label)e.Item.FindControl("Label1")).Text;
            SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=jogi;Integrated Security=True");
            con.Open();
            SqlCommand cmd = new SqlCommand("delete from jogi2 where id='" + id + "'", con);
            int i = cmd.ExecuteNonQuery();
            if (i > 0)
            {
                Label4.Text = "Recard Deleted successfully....";
                GetData();
            }
        }
        protected void DataList1_ItemCommand(object source, DataListCommandEventArgs e)
        {
            if (e.CommandName.Equals("Insert"))
            {
                SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=jogi;Integrated Security=True");
                con.Open();
                TextBox role = (TextBox)e.Item.FindControl("TextBox4");
                TextBox password = (TextBox)e.Item.FindControl("TextBox5");
                SqlCommand cmd = new SqlCommand("insert into jogi2 values('" + role.Text + "','" + password.Text + "')", con);
                int i = cmd.ExecuteNonQuery();
                if (i > 0)
                {
                    Label4.Text = "Recard inserted successfully....";
                    GetData();
                }
            }
        }
        protected void LinkButton5_Click(object sender, EventArgs e)
        {
            Response.Redirect("default2.aspx");
        }
    }

For any problem you are faced hit to reply..
happy coding  :) 

jsb

GeneralSolved: Asp.net datalist control Pin
Otekpo Emmanuel27-Dec-13 5:05
Otekpo Emmanuel27-Dec-13 5:05 
Questionnot able to connect to remote server with filezilla Pin
ank17098922-Dec-13 21:55
ank17098922-Dec-13 21:55 
QuestionRe: not able to connect to remote server with filezilla Pin
ZurdoDev27-Dec-13 10:55
professionalZurdoDev27-Dec-13 10:55 
QuestionHost my website on PC in my network Pin
Tabu9022-Dec-13 21:20
Tabu9022-Dec-13 21:20 
AnswerRe: Host my website on PC in my network Pin
thatraja22-Dec-13 23:54
professionalthatraja22-Dec-13 23:54 
AnswerRe: Host my website on PC in my network Pin
wikizhao24-Dec-13 21:07
wikizhao24-Dec-13 21:07 
AnswerRe: Host my website on PC in my network Pin
wikizhao5-Jan-14 16:05
wikizhao5-Jan-14 16:05 
Questioncreating project Pin
Member 1048191522-Dec-13 4:24
Member 1048191522-Dec-13 4:24 
AnswerRe: creating project Pin
Ron Beyer22-Dec-13 5:41
professionalRon Beyer22-Dec-13 5:41 
QuestionInversion of control Pin
Sumit Bhargav21-Dec-13 21:20
Sumit Bhargav21-Dec-13 21:20 
SuggestionRe: Inversion of control Pin
Richard MacCutchan21-Dec-13 21:24
mveRichard MacCutchan21-Dec-13 21:24 
QuestionService Unavailable error on shared hosting Pin
ank17098921-Dec-13 7:28
ank17098921-Dec-13 7:28 
AnswerRe: Service Unavailable error on shared hosting Pin
Chris Quinn22-Dec-13 21:08
Chris Quinn22-Dec-13 21:08 
Questionplacing a button in the header of a command field tag in grid view control Pin
Ya Rasoolallah20-Dec-13 10:59
Ya Rasoolallah20-Dec-13 10:59 
QuestionUnable to connect to the configured development web server Pin
cstrader20-Dec-13 6:29
cstrader20-Dec-13 6:29 
AnswerRe: Unable to connect to the configured development web server Pin
abdul subhan mohammed21-Dec-13 3:42
professionalabdul subhan mohammed21-Dec-13 3:42 
Questionget same parameter twice Pin
miss78619-Dec-13 0:55
miss78619-Dec-13 0:55 

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.