Monday, December 7, 2009

Ajax Book


Ajax -

Wednesday, November 25, 2009

Huge Book of Puzzles


Hours of fun to fascinate all who love a huge challenge. Quick crosswords, crossword pairs, same and opposite crosswords, 'clueless' crosswords, spinners, word searches, 'spot the difference' puzzles, and all kinds of word and logic puzzles, are here combined together to excite your imagination and test your powers of deduction.
Download Here





















Monday, October 12, 2009

TheUltimate IQ Test Book







The_Ultimate_IQ_Test_Book Download

















Sunday, October 11, 2009

Sql Server Books

SQL Server Stored Procedures



This handbook shows how to write faster and more robust stored procedures and functions, learn effective, real-world solutions to problems faced by database developers, designers, and administrators, and master topics such as optimizing and debugging





Microsoft SQL Server 2000 DTS Step by Step


This introduction to SQL server 2000 data transformation services (DTS) walks step-by-step through the procedures for building an extensible data movement application that periodically moves data from delimited text files.

























Friday, October 9, 2009

Books on ado.net




Programming Microsoft ADO.NET 2.0 Applications: Advanced Topics




Targeting experienced, professional software
developers who design and develop enterprise applications,
 this authoritative reference delves into more than a dozen beyond-the-
basics topics such as ObjectSpaces, the DataView control, and security issues





Apress - ADO Examples and Best Practice
Techniques for advanced programmers
who wish to build efficient database applications using Visual Basic 6.0





Version 2.0 of the .NET Framework will offer
 powerful enhancements to ADO.NET
that will give application and service
developers unprecedented control over their data.
In A First Look at ADO.NET and System.Xml v. 2.0, Microsoft's lead program
 manager on XML technologies joins
 with two leading .NET and XML
experts to present a comprehensive preview of tomorrow'
s ADO.NET and System.Xml classes.









Your Ad Here







Your Ad Here




























Friday, October 2, 2009

XML Step by Step, Second Edition By Michael J. Young








XML Step by Step, Second Edition By Michael J. Young
Publisher: Microsoft Press 2002-02-02 | 488 Pages | ISBN: 0735614652 | PDF | 5.1 MB

Building on the popular first edition, this hands-on learning title demonstrates step by step how to create effective XML documents and display them on the Web. It also reviews the latest W3C standards, shows how to process XML in Microsoft Internet Explorer 6.0 and Microsoft XML Parser (MSXML) 4.0, and expands coverage of namespaces, cascading style sheets (CSS), and other technologies. A companion CD-ROM includes XML examples plus extensive links to further resources.
Download

















Thursday, September 17, 2009

jQuery Reference Guide

This detailed reference guide to jQuery, an open-source JavaScript 
library that shields web developers from browser inconsistencies, 
simplifies adding dynamic, interactive elements, and reduces development 
time, covers the syntax of every jQuery method, function, and selector 
with detailed discussions to help readers get the most from jQuery. 
After analyzing an example jQuery script, detailed reference chapters 
cover the components of jQuery from Selectors to AJAX. The last chapters 
cover jQuery's elegant plug-in architecture and the popular Dimensions 
and Form plug-ins. The book offers web developers both a broad, 
organized view of all that the jQuery library has to offer and a quick a 
reference for comprehensive details. Readers need basic HTML and CSS, 
and familiarity with JavaScript syntax, but no knowledge of jQuery is 
assumed. However, this is not an introductory title and readers starting 
out with jQuery should first read the companion book from Packt, 
Learning jQuery. 


















Thursday, September 3, 2009

XML - Problem-Design-Solution

Offering a unique approach to learning XML, this book walks readers through the process of building a complete, functional, end-to-end XML solution
Featured case study is an online business product catalog that includes reports, data input/output, workflow, stylesheet formatting, RSS feeds, and integration with external services like Google, eBay, and Amazon
The format of presenting a problem and working through the design to come up with a solution enables readers to understand how XML markup allows a business to share data across applications internally or with partners or customers even though they might not use the same applications

Download

Wednesday, September 2, 2009

Building Web Solutions with ASP.NET and ADO.NET.rar

 

Thursday, August 27, 2009

LINQ Unleashed: for C#



Download

Saturday, August 22, 2009

sql CookBook



Download Here

Friday, August 21, 2009

Silverlight For Asp.net



click Here to download

Thursday, August 20, 2009

Rs Aggarwal Reasoning Download

click here to download Rs Aggawalbook

Sql Server In 21 Days

Download Here

Wednesday, August 19, 2009

sql the complete reference

Click Here to Download

Tuesday, August 18, 2009

Add, Edit and Delete using the ASP.NET ListView Control

Monday, August 17, 2009

ASP.NET 2.0 Nested GridView

Wednesday, August 12, 2009

Read Text File and Display in Grid View

protected void Page_Load
(object sender, EventArgs e)
{
if (!IsPostBack)
{
string openpath, contents;
int tabsize = 4;
string[] arinfo;
string line;
int i;
DataTable dt = CreateTable();
DataRow row;
try
{
openpath =
Server.MapPath(".") + @"\abhi.txt";
string filename = openpath;
StreamReader st;
st = File.OpenText(filename);
while ((line = st.ReadLine()) != null)
{
contents =
line.Replace(("").PadRight(tabsize, ' '), "\t");
char[] textdelimeter = { ']' };
arinfo = contents.Split(textdelimeter);
for (i = 0; i < arinfo.Length; i++)
{
row = dt.NewRow();
if (i < arinfo.Length)
row["name"] = arinfo[i].ToString().Replace("[", "");
if (i < arinfo.Length)
row["lastname"] = arinfo[i].ToString().Replace("[", "");
dt.Rows.Add(row);
}
i++;

}
st.Close();
GridView1.DataSource = dt;
GridView1.DataBind();
}
catch (Exception ex)
{
Label1.Text = ex.Message;
}


}


}


private DataTable CreateTable()
{
try
{
DataTable table = new DataTable();

// Declare DataColumn and DataRow variables.
DataColumn column;

// Create new DataColumn, set DataType, ColumnName
// and add to DataTable.
column = new DataColumn();
column.DataType = System.Type.GetType("System.String");
column.ColumnName = "name";
table.Columns.Add(column);

// Create second column.
column = new DataColumn();
column.DataType = Type.GetType("System.String");
column.ColumnName = "lastname";
table.Columns.Add(column);


return table;
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
}
}

Friday, July 31, 2009

Finding the nth highest salary of an employee.

Finding the nth highest salary of an

employee.

CREATE TABLE Employee_Test
(
Emp_ID INT Identity,
Emp_name Varchar(100),
Emp_Sal Decimal (10,2)
)

INSERT INTO Employee_Test VALUES ('Anees',1000);
INSERT INTO Employee_Test VALUES ('Rick',1200);
INSERT INTO Employee_Test VALUES ('John',1100);
INSERT INTO Employee_Test VALUES ('Stephen',1300);
INSERT INTO Employee_Test VALUES ('Maria',1400);

--Highest Salary
select max(Emp_Sal) from Employee_Test

--3rd Highest Salary
select min(Emp_Sal) from Employee_Test where
Emp_Sal in
(select distinct top 3
Emp_Sal from Employee_Test order by Emp_Sal desc)

--nth Highest Salary
select min(Emp_Sal) from Employee_Test
where Emp_Sal in
(select distinct top n Emp_Sal from
Employee_Test order by Emp_Sal desc)



Thursday, July 30, 2009

Sql Transaction with stored procedure

create two table first and create stored procedure

create table emp(emp_id int , empname varchar(25));
create proc emp1
@emp_id int ,
@empname varchar(25)
as
begin
insert into emp values(@emp_id,@empname)
end

create table emp_detail (emp_id int ,city varchar(25));
create proc emp2
@emp_id int,
@city varchar(25)
as
begin
insert into emp_detail values (@emp_id,@city)
end

Then write this code
protected void Button1_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection("data source=.;
initial catalog =abhishek;uid=sa; pwd=computer");
con.Open();
SqlTransaction st;
st = con.BeginTransaction("First");


SqlCommand cmd1 = new SqlCommand();
cmd1.Transaction = st;

try
{

cmd1.Parameters.Add("@emp_id", SqlDbType.Int).Value =
TextBox1.Text;
cmd1.Parameters.Add("@empname", SqlDbType.VarChar, 25).Value =
TextBox2.Text;
cmd1.CommandText = "emp1";
cmd1.CommandType = CommandType.StoredProcedure;
cmd1.Connection = con;

cmd1.ExecuteNonQuery();

cmd2 = new SqlCommand();
cmd2.Transaction = st;

cmd2.Parameters.Add("@emp_id", SqlDbType.Int).Value
= TextBox1.Text;
cmd2.Parameters.Add("@city", SqlDbType.VarChar, 25).Value
= TextBox3.Text;
cmd2.Connection = con;

cmd2.CommandText = "emp2";
cmd2.CommandType = CommandType.StoredProcedure;
cmd2.ExecuteNonQuery();
st.Commit();
}
catch(Exception ex)
{
st.Rollback();
Response.Write(ex.Message.ToString());
}
}

Monday, July 27, 2009

http://www.turboupload.com/wm0alrz7s20y/ASP._NET_3._5_Social_Networking~tqw~_darksiderg.pdf.html

Thursday, July 23, 2009

Visual Studio Keyboard Shortcuts

Key Combination Use Description
CTRL+ALT+L View Solution Explorer Use Auto Hide for all tool windows to maximize screen real estate. Whenever you need to open the Solution Explorer, it’s just a shortcut away.
CTRL+ALT+X View ToolBox .
CTRL+ALT+O View Output .
CTRL+\, then press E View Error List .
CTRL+\, then press T View Task List .
F4 View Property Window Select the control, then press F4 to view property window.
CTRL+PgDn or CTRL+PgUp Design View to Source View and vice-versa Toggle between design and source view in HTML editor.
SHIFT+F7 Design View to Source View and vice-versa Toggle between design and source view in HTML editor.
F7 Design or Source View to Code View Toggle from designer view to code view.
SHIFT+F7 Code View to Design View Toggle from code view to designer view.
F5 Start Debugging .
CTRL+F5 Start Without Debugging .
F10 Debug Step over
F11 Debug Step into
SHIFT+F11 Debug Step out
CTRL+F10 Debug Run to cursor
F9 Toggle Breakpoint .
CTRL+M, then press O Collapse to Definitions. .
CTRL+K, then CTRL+C Comment selected Block .
CTRL+K, then CTRL+U Uncomment selected block .
CTRL+- Go back to the previous location in the navigation history .
F6 Build Solution .
SHIFT+F6 Build Website .
ATL+B, then R Rebuild Solution .
CTRL+L Deletes Entire Line .
CTRL+G GO to the Line Number .
SHIFT+ATL+Enter Toggle Full Screen Mode .
CTRL+Space Invoke the Intellisense List Invokes the intellisence list where cursor pointed.

Saturday, July 18, 2009

SQLSERVER .NET Integration Questions

What are steps to load a .NET code in SQL SERVER 2005?
How can we drop a assembly from SQL SERVER?
Are changes made to assembly updated automatically in database?
Why do we need to drop assembly for updating changes?
How to see assemblies loaded in SQL Server?
I want to see which files are linked with which assemblies?
Does .NET CLR and SQL SERVER run in different process?
Does .NET controls SQL SERVER or is it vice-versa?
Is SQLCLR configured by default?
How to configure CLR for SQL SERVER?
Is .NET feature loaded by default in SQL Server?
How does SQL Server control .NET run-time?
What’s a “SAND BOX” in SQL Server 2005?
What is a application domain?
How are .NET Appdomain allocated in SQL SERVER 2005?
What is Syntax for creating a new assembly in SQL Server 2005?
Do Assemblies loaded in database need actual .NET DLL?
Does SQL Server handle unmanaged resources?
What is Multi-tasking ?
What is Multi-threading ?
What is a Thread ?
Can we have multiple threads in one App domain ?
What is Non-preemptive threading?
What is pre-emptive threading?
Can you explain threading model in SQL Server?
How does .NET and SQL Server thread work?
How are exception in SQLCLR code handled?
Are all .NET libraries allowed in SQL Server?
What is “Hostprotectionattribute” in SQL Server 2005?
How many types of permission level are there for an assembly?
Can you name system tables for .NET assemblies?
Are two version of same assembly allowed in SQL Server?
How are changes made in assembly replicated?
Is it a good practice to drop a assembly for changes?
In one of the projects following steps where done, will it work?
What does Alter assembly with unchecked data signify?
How do I drop an assembly?
Can we creat SQLCLR using .NET framework 1.0?
While creating .NET UDF what checks should be done?
How do you define a function from the .NET assembly?
Can compare between T-SQL and SQLCLR ?
With respect to .NET is SQL SERVER case sensitive?
Does case sensitive rule apply for VB.NET?
Can nested classes be accessed in T-SQL?
Can we have SQLCLR procedure input as array?
Can object datatype be used in SQLCLR?
How’s precision handled for decimal datatypes in .NET?
How do we define INPUT and OUTPUT parameters in SQLCLR?
Is it good to use .NET datatypes in SQLCLR?
How to move values from SQL to .NET datatypes?
What is System.Data.SqlServer?
What is SQLContext?
Can you explain essential steps to deploy SQLCLR?
How do create function in SQL Server using .NET?
How do we create trigger using .NET?
How to create User Define Functions using .NET?
How to create User Defined Create aggregates using .NET?
What is Asynchronous support in ADO.NET?
What is MARS support in ADO.NET?
What is SQLbulkcopy object in ADO.NET ?
How to select range of rows using ADO.NET?

ASP .Net interview Questions

Tough ASP.NET interview questions
Describe the difference between a Thread and a Process?
What is a Windows Service and how does its lifecycle differ from a .standard. EXE?
What is the maximum amount of memory any single process on Windows can address? Is this different than the maximum virtual memory for the system? How would this affect a system design?
What is the difference between an EXE and a DLL?
What is strong-typing versus weak-typing? Which is preferred? Why?
What.s wrong with a line like this? DateTime.Parse(myString
What are PDBs? Where must they be located for debugging to work?
What is cyclomatic complexity and why is it important?
Write a standard lock() plus double check to create a critical section around a variable access.
What is FullTrust? Do GAC’ed assemblies have FullTrust?
What benefit does your code receive if you decorate it with attributes demanding specific Security permissions?
What does this do? gacutil /l | find /i “about”
What does this do? sn -t foo.dll
What ports must be open for DCOM over a firewall? What is the purpose of Port 135?
Contrast OOP and SOA. What are tenets of each
How does the XmlSerializer work? What ACL permissions does a process using it require?
Why is catch(Exception) almost always a bad idea?
What is the difference between Debug.Write and Trace.Write? When should each be used?
What is the difference between a Debug and Release build? Is there a significant speed difference? Why or why not?
Does JITting occur per-assembly or per-method? How does this affect the working set?
Contrast the use of an abstract base class against an interface?
What is the difference between a.Equals(b) and a == b?
In the context of a comparison, what is object identity versus object equivalence?
How would one do a deep copy in .NET?
Explain current thinking around IClonable.
What is boxing?
Is string a value type or a reference type?

ADO.NET Interview Questions

What is the namespace in which .NET has the data functionality classes ?
Can you give a overview of ADO.NET architecture ?
What are the two fundamental objects in ADO.NET ?
What is difference between dataset and datareader ?
What are major difference between classic ADO and ADO.NET ?
What is the use of connection object ?
What is the use of command objects and what are the methods provided by the command object ?
What is the use of dataadapter ?
What are basic methods of Dataadapter ?
What is Dataset object?
What are the various objects in Dataset ?
How can we connect to Microsoft Access , Foxpro , Oracle etc ?
How do we connect to SQL SERVER , which namespace do we use ?
How do we use stored procedure in ADO.NET and how do we provide parameters to the stored procedures?
How can we force the connection object to close after my datareader is closed ?
I want to force the datareader to return only schema of the datastore rather than data ?
How can we fine tune the command object when we are expecting a single row or a single value ?
Which is the best place to store connectionstring in .NET projects ?
What are steps involved to fill a dataset ?(Twist :- How can we use dataadapter to fill a dataset ?)
What are the various methods provided by the dataset object to generate XML?
How can we save all data from dataset ?
How can we check that some changes have been made to dataset since it was loaded ?(Twist :- How can cancel all changes done in dataset ? ,How do we get changed value dataset ? )
How add/remove row’s in “DataTable” object of “DataSet” ?
What’s basic use of “DataView” ?
What’s difference between “DataSet” and “DataReader” ?
How can we load multiple tables in a DataSet ?
How can we add relation’s between table in a DataSet ?
What’s the use of CommandBuilder ?
What’s difference between “Optimistic” and “Pessimistic” locking ?
How many way’s are there to implement locking in ADO.NET ?
How can we perform transactions in .NET?
What’s difference between Dataset. clone and Dataset. copy ?

HTML Interview Questions

How to create links to sections on the same page in HTML.
How do I create forums for my webpage?
How can I get more traffic or people to visit my website?
How can I check if anyone is stealing my website content?
How can I get more visitors on my forum?
Creating a web page with a single background image not a tiled background.
Opening new web page window when clicking on a link.
Creating a new window in HTML for a single image.
Creating multicolor links in HTML.
How to create a fixed background image on a web page.
How to create a counter on your web page.
How to resize an image with HTML.
Getting subject added to the mailto command.
How can I copyright or otherwise protect my images online?
After uploading an update to my webpage it looks the same.
Internet Explorer error: Done, but with errors on page.
How do I indent text on my web page or in HTML?
Why does alt text in the html img tag not work in Firefox?
Forum If your question is not listed on this page please try our online forum.
How do I view the source code of a web page?
Creating a mail link on a web page.
Creating flashing background when opening a web page.
Linking an image to another page in HTML.
Creating images as links with no borders.
Allowing user to choose their background color.
Creating a HTML text field bigger then one line.
What is HTML?
Creating unformatted HTML text.
Transferring user to new web page automatically.
Creating three images: first on left, second centered, third on right.
Defining the background and text color.
Is it possible to make the HTML source not viewable?
Creating images that are right aligned with the web page window.
Creating an image with a text description in HTML.
Creating a link to play a sound file in HTML.
Changing the type of font displayed on web page.
How to create a link to automatically run .exe file once downloaded.
Creating a link without an underline in HTML.
Changing link color when moving mouse over link in HTML.
Creating HTML push button link.
Creating simple search for your web page.
Creating an Onmouse over for images in HTML.
Creating script to break web page out of frames.
Accepting credit card on web page.
How do I close a browser window with HTML code?
Creating a HTML back button.
Information about favicon.ico.
How can I insert a movie into a HTML document?
How do I make money on my website?
How to create a guestbook on your web page.
How can I copy something from a webpage to my webpage?

Tuesday, July 7, 2009

Gridview With DropdownList Update



<asp:GridView ID="GridView1" runat="server"
AutoGenerateColumns="False"
onrowdatabound="GridView1_RowDataBound"
onrowediting="GridView1_RowEditing"
onrowupdating="GridView1_RowUpdating">
<Columns>
<asp:TemplateField HeaderText="Edit"
ShowHeader="false">
<ItemTemplate>
<asp:LinkButton ID="btnedit"
runat="server"
CommandName="Edit" Text="Edit" ></asp:
LinkButton>
</ItemTemplate>
<EditItemTemplate>
<asp:LinkButton ID="btnupdate" runat="server"
CommandName="Update" Text="Update"
></asp:LinkButton>
<asp:LinkButton ID="btncancel" runat="server"
CommandName="Cancel" Text="Cancel"></asp:LinkButton>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="id">
<ItemTemplate>
<asp:Label ID="id" runat="server"
Text='<%#Eval("id") %
>'></asp:Label>

</ItemTemplate>

</asp:TemplateField>
<asp:TemplateField HeaderText="city">
<ItemTemplate>
<asp:Label ID="city" runat="server"
Text='<%#Eval("city")
%>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:DropDownList ID="dropcity" runat="server"></
asp:DropDownList>
<asp:RequiredFieldValidator ID="vali" runat="server"
ControlToValidate="dropcity"
ErrorMessage="*"><
/asp:RequiredFieldValidator>
</EditItemTemplate>
</asp:TemplateField>

</Columns>

</asp:GridView>



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;
namespace dropdownwithgrid
{
public partial class _Default : System.Web.UI.Page
{
SqlConnection sqlcon = new SqlConnection("Data Source=.;
Initial Catalog=abhishek;Persist Security Info=True;User ID=sa;
Password=sa");
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
binddata();

}
}

public void binddata()
{
DataTable dt = new DataTable();

sqlcon.Open();
SqlDataAdapter sda = new SqlDataAdapter();
string strQuery = "select id,city from id ";
SqlCommand cmd = new SqlCommand(strQuery);
cmd.CommandType = CommandType.Text;
cmd.Connection = sqlcon;
sda.SelectCommand = cmd;
sda.Fill(dt);
GridView1.DataSource = dt;
GridView1.DataBind();
sqlcon.Close();
}

protected void GridView1_RowUpdating(object sender,
GridViewUpdateEventArgs e)
{
Label l1 = (Label)GridView1.Rows[e.RowIndex].FindControl("id");
DropDownList d1 = (DropDownList)GridView1.Rows[e.RowIndex].
FindControl("dropcity");
sqlcon.Open();
SqlCommand cmd = new SqlCommand();
cmd.Connection = sqlcon;
cmd.CommandText = "update id set city='" +
d1.SelectedValue.ToString() + "' where id='" + l1.Text + "'";
cmd.ExecuteNonQuery();
GridView1.EditIndex = -1;
binddata();
}

protected void GridView1_RowEditing(object sender,
GridViewEditEventArgs e)
{
GridView1.EditIndex = e.NewEditIndex;
binddata();

}
public DataTable load_City()
{
// sqlcon.Open();
DataTable dt = new DataTable();


string sql = "select city from id";
SqlCommand cmd = new SqlCommand(sql);
cmd.CommandType = CommandType.Text;
cmd.Connection = sqlcon;
SqlDataAdapter sd = new SqlDataAdapter(cmd);
sd.Fill(dt);

return dt;


}
protected void GridView1_RowDataBound(object sender,
GridViewRowEventArgs e)
{
DataRowView drv = e.Row.DataItem as DataRowView;
if (e.Row.RowType == DataControlRowType.DataRow)
{
if ((e.Row.RowState & DataControlRowState.Edit) > 0)
{
DropDownList dp = (DropDownList)e.Row.FindControl("dropcity");
DataTable dt = load_City();
for (int i = 0; i < dt.Rows.Count; i++)
{
ListItem lt = new ListItem();
lt.Text = dt.Rows[i][0].ToString();
dp.Items.Add(lt);
}
dp.SelectedValue = drv[1].ToString();
}
}

}
}
}

Friday, July 3, 2009

Paging in Detail View

 <asp:DetailsView ID="DetailsView1" runat="server"
AutoGenerateRows="False"

DataKeyNames="EmployeeID"
DataSourceID="SqlDataSource1" Height="50px"

Width="125px" AllowPaging="true">

<Fields>
<asp:BoundField DataField="EmployeeID"
HeaderText="EmployeeID"

InsertVisible="False" ReadOnly="True"
SortExpression="EmployeeID" />

<asp:BoundField DataField="LastName"
HeaderText="LastName"

SortExpression="LastName" />
<asp:BoundField DataField="FirstName"
HeaderText="FirstName"

SortExpression="FirstName" />
<asp:BoundField DataField="Title" HeaderText="Title"
SortExpression="Title"
/>

<asp:BoundField DataField="TitleOfCourtesy"
HeaderText="TitleOfCourtesy"

SortExpression="TitleOfCourtesy" />
<asp:BoundField DataField="BirthDate"
HeaderText="BirthDate"

SortExpression="BirthDate" />
</Fields>
<PagerSettings Mode="NextPreviousFirstLast"
FirstPageText="[First Page]"
LastPageText="[LastPage]"
PreviousPageText="[PreviousPage]"
NextPageText="[NextPage]" />
</asp:DetailsView>
<br />
<br />
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<
%$ ConnectionStrings:NorthwindConnectionString %>"

SelectCommand="SELECT [EmployeeID],
[LastName], [FirstName], [Title],
[TitleOfCourtesy], [BirthDate] FROM [Employees]">

</asp:SqlDataSource>

Wednesday, June 24, 2009

Update in Repeater



Code

public partial class Default2 : System.Web.UI.Page
{
Button b1, b2, b3;
SqlConnection conn = new SqlConnection("Data Source=.;Initial Catalog=abhishek;Persist Security Info=True;uid=sa;pwd=com");
SqlCommand cmd = new SqlCommand();
protected void Page_Load(object sender, EventArgs e)
{
if(!IsPostBack)
{
bindgrid();
}


}

public void bindgrid()
{
SqlDataAdapter da = new SqlDataAdapter("select * from ab", conn);
DataSet ds = new DataSet();
da.Fill(ds);
Repeater1.DataSource = ds;
Repeater1.DataBind();
}
protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
{
TextBox t1, t2;
if (e.CommandName =="Edit")
{
t1 = (TextBox)Repeater1.Items[e.Item.ItemIndex].FindControl("id1");
t2 = (TextBox)Repeater1.Items[e.Item.ItemIndex].FindControl("name");
t1.ReadOnly = false;
t2.ReadOnly = false;

b1 = (Button)e.Item.FindControl("b1");
b1.CommandName = "update";
b1.Text = "update";

}
else if (e.CommandName == "update")
{
t1 = (TextBox)Repeater1.Items[e.Item.ItemIndex].FindControl("id1");
t2 = (TextBox)Repeater1.Items[e.Item.ItemIndex].FindControl("name");
int i = int.Parse(t1.Text);


cmd.Connection = conn;
conn.Open();
cmd.CommandText="update ab set name='"+t2.Text+"' where id ='"+i+"'";
cmd.ExecuteNonQuery();
Repeater1.DataBind();
conn.Close();
bindgrid();



}
if (e.CommandName == "Insert")
{
b3 = (Button)e.Item.FindControl("b3");
b3.Text = "save";
t1 = (TextBox)Repeater1.Items[e.Item.ItemIndex].FindControl("id1");
t2 = (TextBox)Repeater1.Items[e.Item.ItemIndex].FindControl("name");
t1.ReadOnly = false;
t2.ReadOnly = false;
cmd.Connection = conn;
conn.Open();
cmd.CommandText = "insert into ab values('" + t1.Text + "','" + t2.Text + "')";
cmd.ExecuteNonQuery();
conn.Close();
bindgrid();

}
}




Code