TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
haleema sher
NA
2
0
IListSource does not contain any data sources
Jul 2 2009 4:45 AM
i face this error during runtime of my website in asp.net and C#. plz chk my code and reply
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;
using
System.Data.SqlTypes;
public
partial
class
Default2
: System.Web.UI.
Page
{
SqlConnection
cnx =
new
SqlConnection
(
"Data Source=.\\SQLEXPRESS;AttachDbFilename=|DataDirectory|Coupon Management.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"
);
SqlDataAdapter
da1 =
new
SqlDataAdapter
();
DataSet
ds =
new
DataSet
();
SqlCommand
cmd =
new
SqlCommand
();
DataTable
dataTable;
protected
void
Page_Load(
object
sender,
EventArgs
e)
{
if
(!IsPostBack)
{
FillVendorGrid();
}
}
private
void
FillVendorGrid()
{
dataTable =
new
DataTable
();
cmd.Connection = cnx;
cmd.CommandText =
"SELECT Coupon_Info.RecievingDate, CouponType.CouponName, Coupon_Info.Serial_Start, Coupon_Info.Serial_End, Coupon_Info.Recieved_By FROM Coupon_Info INNER JOIN CouponType ON Coupon_Info.Coupon_TypeID = CouponType.CouponTypeID"
;
da1 =
new
SqlDataAdapter
(cmd);
da1.Fill(dataTable);
GridView1.DataSource = dataTable;
GridView1.DataSource = ds;
GridView1.DataSourceID =
String
.Empty;
//GridView1.DataBind();
// GridView1.DataSource = ds;
// GridView1.DataBind();
}
protected
void
GridView1_PageIndexChanging(
object
sender,
GridViewPageEventArgs
e)
{
GridView1.PageIndex = e.NewPageIndex;
FillVendorGrid();
}
protected
void
GridView1_RowDeleting(
object
sender,
GridViewDeleteEventArgs
e)
{
cmd.Connection = cnx;
cmd.CommandText =
"DELETE FROM Coupon_Info WHERE RecievingDate='"
+ GridView1.DataKeys[e.RowIndex].Values[0].ToString() +
"'"
;
cnx.Open();
cmd.ExecuteNonQuery();
cnx.Close();
FillVendorGrid();
}
}
Reply
Answers (
0
)
Update xml file without deleting it first?
Convert string to ascii values