Click here to Skip to main content
15,909,953 members

Comments by poongunrans (Top 6 by date)

poongunrans 7-Aug-12 4:53am View    
Could you show us you code, then only help your problem
poongunrans 7-Aug-12 4:50am View    
{ string id = data_list.DataKeys[e.Item.ItemIndex].ToString();
string query = "delete from Book_Candidates where candidate_id='" + id + "'";
SqlConnection theConnection = new SqlConnection(con);

SqlCommand theCommand = new SqlCommand(query, theConnection);
theConnection.Open();
theCommand.ExecuteNonQuery();
theConnection.Close();

Bind();
}
protected void DataList1_ItemCommand(object source, DataListCommandEventArgs e)
{

TextBox tst = (TextBox)e.Item.FindControl("Add_user");
string query = "insert into Book_Candidates(candidate_first_name) values('" + tst .Text+ "')";
SqlConnection theConnection = new SqlConnection(con);
SqlCommand theCommand = new SqlCommand(query, theConnection);
theConnection.Open();
theCommand.ExecuteNonQuery();
theConnection.Close();
Bind();

}
public void Bind()
{
string query = "select candidate_id,candidate_first_name from Book_Candidates";
SqlConnection theConnection = new SqlConnection(con);
SqlCommand theCommand = new SqlCommand(query, theConnection);
SqlDataAdapter da = new SqlDataAdapter(theCommand);
DataSet ds = new DataSet();
da.Fill(ds);
data_list.DataSource = ds;
data_list.DataBind();
}
}
poongunrans 7-Aug-12 4:50am View    
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="datalistall.aspx.cs" Inherits="datalistall" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:DataList ID="data_list" runat="server"
OnCancelCommand="DataList1_CancelCommand"
OnDeleteCommand="DataList1_DeleteCommand"
OnEditCommand="DataList1_EditCommand"
OnUpdateCommand="DataList1_UpdateCommand"
OnItemCommand="DataList1_ItemCommand"
DataKeyField="candidate_id">
<itemtemplate>
<div align="center">
<table width="300">
<tr>
<td style="width:60%;"><asp:Label ID="name_lbl" runat="server" Text='<%#Eval("candidate_first_name") %>' /></td>
<td><asp:LinkButton ID="edit_link" runat="server" Text="Edit" CommandName="Edit" /></td>
<td><asp:LinkButton ID="delete_link" runat="server" Text="Delete" CommandName="Delete" /></td>
</tr>
</table>
</div>

<edititemtemplate>
<table width="300">
<tr>
<td style="width:60%;"><asp:TextBox ID="user_txt" runat="server" Text='<%#Eval("candidate_first_name") %>' /></td>
<td><asp:LinkButton ID="update_link" runat="server" CommandName="Update" Text="Update" /></td>
<td><asp:LinkButton ID="cancel_link" runat="server" CommandName="Cancel" Text="Cancel" /></td>
</tr>
</table>

<HeaderTemplate>
<table width="300">
<tr>
<td style="width:60%;">Uer Name</td>
<td colspan="2">Action</td>

</tr>
</table>
</HeaderTemplate>
<footertemplate>
<table width="300">
<tr>
<td style="width:60%;"><asp:TextBox ID="Add_user" runat="server" Text='<%#Eval("candidate_first_name") %>' /></td>
<td colspan="2"><asp:LinkButton ID="Add_link" runat="server" CommandName="Insert" Text="Insert" /></td>

</tr>
</table>
</table>


</div>
</form>
</body>
</html>


server coding


using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;

public partial class datalistall : System.Web.UI.Page
{
string con = ConfigurationSettings.AppSettings["vivaagaConnectionString"];
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
Bind();
}
}
protected void DataList1_EditCommand(object source, DataListCommandEventArgs e)
{
data_list.EditItemIndex = e.Item.ItemIndex;
Bind();
}
protected void DataList1_UpdateCommand(object source, DataListCommandEventArgs e)
{
string id = data_list.DataKeys[e.Item.ItemIndex].ToString();
TextBox tst = (TextBox)e.Item.FindControl("user_txt");
string query = "update Book_Candidates set candidate_first_name='" + tst .Text+ "' where candidate_id='" + id + "'";
SqlConnection theConnection = new SqlConnection(con);

SqlCommand theCommand = new SqlCommand(query, theConnection);
theConnection.Open();
theCommand.ExecuteNonQuery();
theConnection.Close();
data_list.EditItemIndex = -1;
Bind();
}
protected void DataList1_CancelCommand(object source, DataListCommandEventArgs e)
{
data_list.EditItemIndex = -1;
Bind();
}
protected void DataList1_DeleteCommand(object source, DataListCommandE
poongunrans 7-Aug-12 3:42am View    
using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;

public partial class _Default : System.Web.UI.Page
{

string con=ConfigurationSettings.AppSettings["vivaagaConnectionString"]

protected void Page_Load(object sender, EventArgs e)
{

}
protected void AddListItem_Click(object sender, EventArgs e)
{
string query="select user_id,user_name from user where active_flag='A'";
SqlConnection theConnection = new SqlConnection(con);
SqlCommand theCommand=new SqlCommand(query,theConnection);
SqlDataAdapter da=new SqlDataAdapter(theCommand);
DataSet ds=new DataSet();
da.Fill(ds);
Add_lst.DataTextField="user_name";
Add_lst.DataValueField="user_id";
Add_lst.DataSource=ds;
Add_lst.DataBind();

}
}
poongunrans 7-Aug-12 3:35am View    
Added your coding with in update pannel.. then only without refers the page