protected void btnModify_Click(object sender, EventArgs e)
{
DataClassesDataContext dbcontext = new DataClassesDataContext();
var VideoList = (from vl in dbcontext.VideoTables where vl.VideoID == Convert.ToInt32(ViewState["VideoID"]) select vl).Single();
if (VideoList != null)
{
VideoTable vt = new VideoTable();
VideoList.VideoHeading = txtVideoHeading.Text;
VideoList.VideoLink = txtVideoLink.Text;
VideoList.Remark = txtRemark.Text;
}
try
{
dbcontext.SubmitChanges();
loadVideoGrid();
BAL.Sangram.alert("Record Updateed Successfully.....", "", true);
return;
}
catch
{
BAL.Sangram.alert("Some Error Occured.....", "", true);
return;
}
}
----------------------------------------------------------
protected void gdvVideo_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
string videoId = gdvVideo.DataKeys[e.RowIndex]["VideoID"].ToString();
DataClassesDataContext dbcontext = new DataClassesDataContext();
var vID = (from VlR in dbcontext.VideoTables where VlR.VideoID == Convert.ToInt32(videoId) select VlR).Single();
try
{
dbcontext.VideoTables.DeleteOnSubmit(vID);
dbcontext.SubmitChanges();
loadVideoGrid();
BAL.Sangram.alert("Record Deleted Successfully.....", "", true);
return;
}
catch
{
BAL.Sangram.alert("Some Error Occured.....", "", true);
return;
}
}
-----------------------------------------------------------------
protected void gdvVideo_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
{
ViewState["VideoID"] = gdvVideo.DataKeys[e.NewSelectedIndex]["VideoID"].ToString();
DataClassesDataContext dbcontext = new DataClassesDataContext();
var vidiolist = from vl in dbcontext.VideoTables where vl.VideoID == Convert.ToInt32(ViewState["VideoID"]) select vl;
if (vidiolist != null)
{
txtVideoHeading.Text = vidiolist.FirstOrDefault().VideoHeading.ToString();
txtVideoLink.Text = vidiolist.FirstOrDefault().VideoLink.ToString();
txtRemark.Text = vidiolist.FirstOrDefault().Remark.ToString();
btnModify.Visible = true;
btnSave.Visible = false;
}
}
---------------------------------------------------------------
private void loadVideoGrid()
{
DataClassesDataContext dbcontext = new DataClassesDataContext();
var vedioList = from vl in dbcontext.VideoTables select vl;
gdvVideo.DataSource = vedioList;
gdvVideo.DataBind();
}
{
DataClassesDataContext dbcontext = new DataClassesDataContext();
var VideoList = (from vl in dbcontext.VideoTables where vl.VideoID == Convert.ToInt32(ViewState["VideoID"]) select vl).Single();
if (VideoList != null)
{
VideoTable vt = new VideoTable();
VideoList.VideoHeading = txtVideoHeading.Text;
VideoList.VideoLink = txtVideoLink.Text;
VideoList.Remark = txtRemark.Text;
}
try
{
dbcontext.SubmitChanges();
loadVideoGrid();
BAL.Sangram.alert("Record Updateed Successfully.....", "", true);
return;
}
catch
{
BAL.Sangram.alert("Some Error Occured.....", "", true);
return;
}
}
----------------------------------------------------------
protected void gdvVideo_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
string videoId = gdvVideo.DataKeys[e.RowIndex]["VideoID"].ToString();
DataClassesDataContext dbcontext = new DataClassesDataContext();
var vID = (from VlR in dbcontext.VideoTables where VlR.VideoID == Convert.ToInt32(videoId) select VlR).Single();
try
{
dbcontext.VideoTables.DeleteOnSubmit(vID);
dbcontext.SubmitChanges();
loadVideoGrid();
BAL.Sangram.alert("Record Deleted Successfully.....", "", true);
return;
}
catch
{
BAL.Sangram.alert("Some Error Occured.....", "", true);
return;
}
}
-----------------------------------------------------------------
protected void gdvVideo_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
{
ViewState["VideoID"] = gdvVideo.DataKeys[e.NewSelectedIndex]["VideoID"].ToString();
DataClassesDataContext dbcontext = new DataClassesDataContext();
var vidiolist = from vl in dbcontext.VideoTables where vl.VideoID == Convert.ToInt32(ViewState["VideoID"]) select vl;
if (vidiolist != null)
{
txtVideoHeading.Text = vidiolist.FirstOrDefault().VideoHeading.ToString();
txtVideoLink.Text = vidiolist.FirstOrDefault().VideoLink.ToString();
txtRemark.Text = vidiolist.FirstOrDefault().Remark.ToString();
btnModify.Visible = true;
btnSave.Visible = false;
}
}
---------------------------------------------------------------
private void loadVideoGrid()
{
DataClassesDataContext dbcontext = new DataClassesDataContext();
var vedioList = from vl in dbcontext.VideoTables select vl;
gdvVideo.DataSource = vedioList;
gdvVideo.DataBind();
}
No comments:
Post a Comment