|
first implement it vipul add it tell me if you need a help
|
|
|
|
|
|
I need your help when I insert record then it cant insert in database.
|
|
|
|
|
|
aspx page is :
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" BackColor="#f1f1f1"
AutoGenerateColumns=false DataSourceID="SqlDataSource1" DataKeyNames="ShowTimeId"
GridLines=None OnRowDataBound="GridView1_RowDataBound"
OnRowCommand = "GridView1_RowCommand" OnRowUpdating = "GridView1_RowUpdating" BorderStyle=Outset
OnRowDeleting = "GridView1_RowDeleting" OnRowDeleted = "GridView1_RowDeleted"
OnRowUpdated = "GridView1_RowUpdated" AllowSorting=true ShowFooter=true
Width="100%" >
<RowStyle BackColor="Gainsboro" />
<AlternatingRowStyle BackColor="White" />
<HeaderStyle BackColor="#0083C1" ForeColor="White"/>
<FooterStyle BackColor="White" />
<Columns>
<asp:TemplateField>
<ItemTemplate>
<a href="javascript:expandcollapse('div<%# Eval("ShowTimeId") %>', 'one');">
<img id="imgdiv<%# Eval("ShowTimeId") %>" alt="Click to show/hide Orders for Customer <%# Eval("ShowTimeId") %>" width="9px" border="0" src="../images/plus.gif"/>
</a>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="ShowTime Id" SortExpression="ShowTimeId">
<ItemTemplate>
<asp:Label ID="lblShowTimeId" Text='<%# Eval("ShowTimeId") %>' runat="server"></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:Label ID="lblShowTimeId" Text='<%# Eval("ShowTimeId") %>' runat="server"></asp:Label>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Theatre Id" SortExpression="TheatreId">
<ItemTemplate>
<asp:Label ID="lblTheatreId" Text='<%# Eval("TheatreId") %>' runat="server"></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:Label ID="lblTheatreId" Text='<%# Eval("TheatreId") %>' runat="server"></asp:Label>
</EditItemTemplate>
<FooterTemplate>
<asp:DropDownList ID="ddlTheatre" runat="server" CssClass="form_input" AutoPostBack="True" TabIndex="1"
DataSourceID="SqlDataSource2" DataTextField="TheatreName" DataValueField="TheatreID" Width="130px"
SelectedValue='<%# Bind("TheaterName") %>'>
</asp:DropDownList>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Movie Id" SortExpression="MovieId">
<ItemTemplate>
<asp:Label ID="lblMovieId" Text='<%# Eval("MovieName") %>' runat="server"></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:DropDownList ID="ddlmovie" runat="server" CssClass="form_input" TabIndex="2" Width="130px">
</asp:DropDownList>
</EditItemTemplate>
<FooterTemplate>
<asp:DropDownList ID="ddlMovie" runat="server" CssClass="form_input" TabIndex="2" Width="130px">
</asp:DropDownList>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="From Date" SortExpression="FromDate">
<ItemTemplate><%# Eval("FromDate")%></ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtFromDate" Text='<%# Eval("FromDate") %>' runat="server"></asp:TextBox>
<asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="~/cal/calendar.gif" AlternateText="Click to show calendar" TabIndex="3" />
<asp:CalendarExtender ID="CalendarExtender1" runat="server" TargetControlID="txtFromDate" Format="dd/MM/yyyy" PopupButtonID="ImageButton1">
</asp:CalendarExtender>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtFromDate" Text='' runat="server"></asp:TextBox>
<asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="~/cal/calendar.gif" AlternateText="Click to show calendar" TabIndex="3" />
<asp:CalendarExtender ID="CalendarExtender1" runat="server" TargetControlID="txtFromDate" Format="dd/MM/yyyy" PopupButtonID="ImageButton1">
</asp:CalendarExtender>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="To Date" SortExpression="ToDate">
<ItemTemplate><%# Eval("ToDate")%></ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtToDate" Text='<%# Eval("ToDate") %>' runat="server"></asp:TextBox>
<asp:ImageButton ID="ImageButton2" runat="server" ImageUrl="~/cal/calendar.gif" AlternateText="Click to show calendar" TabIndex="3" />
<asp:CalendarExtender ID="CalendarExtender2" runat="server" TargetControlID="txtToDate" Format="dd/MM/yyyy" PopupButtonID="ImageButton2">
</asp:CalendarExtender>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtToDate" Text='' runat="server"></asp:TextBox>
<asp:ImageButton ID="ImageButton2" runat="server" ImageUrl="~/cal/calendar.gif" AlternateText="Click to show calendar" TabIndex="3" />
<asp:CalendarExtender ID="CalendarExtender2" runat="server" TargetControlID="txtToDate" Format="dd/MM/yyyy" PopupButtonID="ImageButton2">
</asp:CalendarExtender>
</FooterTemplate>
</asp:TemplateField>
<asp:CommandField HeaderText="Edit" ShowEditButton="True" />
<asp:TemplateField HeaderText="Delete">
<ItemTemplate>
<asp:LinkButton ID="linkDeleteShow" CommandName="Delete" runat="server">Delete</asp:LinkButton>
</ItemTemplate>
<FooterTemplate>
<asp:LinkButton ID="linkAddShow" CommandName="AddShow" runat="server">Add</asp:LinkButton>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<tr>
<td colspan="100%">
<div id="div<%# Eval("ShowTimeId") %>" style="display:none;position:relative;left:15px;OVERFLOW: auto;WIDTH:97%" >
<asp:GridView ID="GridView2" AllowPaging="True" AllowSorting="true" BackColor="White" Width=100% Font-Size=X-Small
AutoGenerateColumns="false" Font-Names="Verdana" runat="server" ShowFooter="true"
OnPageIndexChanging="GridView2_PageIndexChanging" OnRowUpdating = "GridView2_RowUpdating" CssClass="Gridview"
OnRowCommand = "GridView2_RowCommand" OnRowEditing = "GridView2_RowEditing" GridLines=None
OnRowUpdated = "GridView2_RowUpdated" OnRowCancelingEdit = "GridView2_CancelingEdit" OnRowDataBound = "GridView2_RowDataBound"
OnRowDeleting = "GridView2_RowDeleting" OnRowDeleted = "GridView2_RowDeleted" OnSorting = "GridView2_Sorting"
BorderStyle=Double BorderColor="#0083C1">
<RowStyle BackColor="Gainsboro" />
<AlternatingRowStyle BackColor="White" />
<HeaderStyle BackColor="#0083C1" ForeColor="White"/>
<FooterStyle BackColor="White" />
<Columns>
<asp:TemplateField HeaderText="Show ID" SortExpression="ShowID">
<ItemTemplate>
<asp:Label ID="lblShowID" Text='<%# Eval("ShowID") %>' runat="server"></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:Label ID="lblShowID" Text='<%# Eval("ShowID") %>' runat="server"></asp:Label>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="ShowTime" SortExpression="ShowTime">
<ItemTemplate><%# Eval("ShowTime")%></ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtShowTime" Text='<%# Eval("ShowTime")%>' runat="server"></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtShowTime" Text='' runat="server"></asp:TextBox>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Silver" SortExpression="Silver">
<ItemTemplate><%# Eval("Silver")%></ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtSilver" Text='<%# Eval("Silver")%>' runat="server"></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtSilver" Text='' runat="server"></asp:TextBox>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Gold" SortExpression="Gold">
<ItemTemplate><%# Eval("Gold")%></ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtGold" Text='<%# Eval("Gold")%>' runat="server"></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtGold" Text='' runat="server"></asp:TextBox>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Platinum" SortExpression="Platinum">
<ItemTemplate><%# Eval("Platinum")%></ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtPlatinum" Text='<%# Eval("Platinum")%>' runat="server"></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtPlatinum" Text='' runat="server"></asp:TextBox>
</FooterTemplate>
</asp:TemplateField>
<asp:CommandField HeaderText="Edit" ShowEditButton="True" />
<asp:TemplateField HeaderText="Delete">
<ItemTemplate>
<asp:LinkButton ID="linkDeleteCust" CommandName="Delete" runat="server">Delete</asp:LinkButton>
</ItemTemplate>
<FooterTemplate>
<asp:LinkButton ID="linkAddOrder" CommandName="AddShow" runat="server">Add</asp:LinkButton>
</FooterTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
</td>
</tr>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:Event_MovieConnectionString %>"
SelectCommand="SELECT s.[ShowTimeId], s.[TheatreId], s.[MovieId], s.[FromDate], s.[ToDate], s.[Created],
s.[Modified], t.TheatreID, t.TheatreName, m.MovieID, m.MovieName FROM (([tbl_SShow] s inner join MST_Theatre t
on s.TheatreId = t.TheatreID)inner join MST_Movie m on s.MovieId = m.MovieID) ORDER BY s.[ShowTimeId]">
</asp:SqlDataSource>
<asp:SqlDataSource ID="SqlDataSource2" runat="server"
ConnectionString="<%$ ConnectionStrings:Event_MovieConnectionString %>"
SelectCommand="SELECT TheatreID, TheatreName FROM MST_Theatre">
</asp:SqlDataSource>
and CS file is :
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.Drawing;
using BLL;
public partial class _Default : System.Web.UI.Page
{
clsbll b1 = new clsbll();
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["MyConn"].ConnectionString.ToString());
string gvUniqueID = String.Empty;
int gvNewPageIndex = 0;
int gvEditIndex = -1;
string gvSortExpr = String.Empty;
private string gvSortDir
{
get { return ViewState["SortDirection"] as string ?? "ASC"; }
set { ViewState["SortDirection"] = value; }
}
//This procedure returns the Sort Direction
private string GetSortDirection()
{
switch (gvSortDir)
{
case "ASC":
gvSortDir = "DESC";
break;
case "DESC":
gvSortDir = "ASC";
break;
}
return gvSortDir;
}
//This procedure prepares the query to bind the child GridView
private SqlDataSource ChildDataSource(string strShowTimeId, string strSort)
{
string strQRY = "";
SqlDataSource dsTemp = new SqlDataSource();
dsTemp.ConnectionString = ConfigurationManager.ConnectionStrings["MyConn"].ConnectionString.ToString();
//dsTemp.DataFile = "App_Data/Northwind.mdb";
strQRY = "SELECT [tbl_Time].[ShowID],[tbl_Time].[ShowTime]," +
"[tbl_Time].[Silver],[tbl_Time].[Gold],[tbl_Time].[Platinum] FROM [tbl_Time]" +
" WHERE [tbl_Time].[ShowTimeId] = '" + strShowTimeId + "'" +
"UNION ALL " +
"SELECT '" + strShowTimeId + "','','','','' FROM [tbl_Time] WHERE [tbl_Time].[ShowTimeId] = '" + strShowTimeId + "'" +
"HAVING COUNT(*)=0 " + strSort;
dsTemp.SelectCommand = strQRY;
return dsTemp;
}
protected void Page_Load(object sender, EventArgs e)
{
}
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
// start ddlMovie
if (e.Row.RowType == DataControlRowType.DataRow)
{
DropDownList cmbType = (DropDownList)e.Row.FindControl("ddlmovie");
if (cmbType != null)
{
SqlCommand cmd = new SqlCommand("select MovieName from MST_Movie ", con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt);
cmbType.DataSource = dt;
cmbType.DataTextField = "MovieName";
cmbType.DataValueField = "MovieName";
cmbType.DataBind();
cmbType.SelectedValue = GridView1.DataKeys[e.Row.RowIndex].Values[0].ToString();
}
}
if (e.Row.RowType == DataControlRowType.Footer)
{
DropDownList cmbNewType = (DropDownList)e.Row.FindControl("ddlMovie");
SqlCommand cmd = new SqlCommand("select MovieName from MST_Movie", con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt);
cmbNewType.DataTextField = "MovieName";
cmbNewType.DataValueField = "MovieName";
cmbNewType.DataSource = dt;
cmbNewType.DataBind();
}
// end ddlMovie
GridViewRow row = e.Row;
string strSort = string.Empty;
// Make sure we aren't in header/footer rows
if (row.DataItem == null)
{
return;
}
//Find Child GridView control
GridView gv = new GridView();
gv = (GridView)row.FindControl("GridView2");
//Check if any additional conditions (Paging, Sorting, Editing, etc) to be applied on child GridView
if (gv.UniqueID == gvUniqueID)
{
gv.PageIndex = gvNewPageIndex;
gv.EditIndex = gvEditIndex;
//Check if Sorting used
if (gvSortExpr != string.Empty)
{
GetSortDirection();
strSort = " ORDER BY " + string.Format("{0} {1}", gvSortExpr, gvSortDir);
}
//Expand the Child grid
ClientScript.RegisterStartupScript(GetType(), "Expand", "<SCRIPT LANGUAGE='javascript'>expandcollapse('div" + ((DataRowView)e.Row.DataItem)["ShowTimeId"].ToString() + "','one');</script>");
}
//Prepare the query for Child GridView by passing the Customer ID of the parent row
gv.DataSource = ChildDataSource(((DataRowView)e.Row.DataItem)["ShowTimeId"].ToString(), strSort);
gv.DataBind();
//Add delete confirmation message for Customer
LinkButton l = (LinkButton)e.Row.FindControl("linkDeleteShow");
l.Attributes.Add("onclick", "javascript:return " +
"confirm('Are you sure you want to delete this Show " +
DataBinder.Eval(e.Row.DataItem, "ShowTimeId") + "')");
}
//This event occurs for any operation on the row of the grid
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
//Check if Add button clicked
if (e.CommandName == "AddShow")
{
try
{
//Get the values stored in the text boxes
DropDownList strTheatreid = ((DropDownList)GridView1.FooterRow.FindControl("ddlTheatre"));
DropDownList strMovieid = ((DropDownList)GridView1.FooterRow.FindControl("ddlMovie"));
TextBox strFromDate = ((TextBox)GridView1.FooterRow.FindControl("txtFromDate"));
TextBox strToDate = ((TextBox)GridView1.FooterRow.FindControl("txtToDate"));
DateTime fromdate = DateTime.ParseExact(strFromDate.Text, "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture);
DateTime Todate = DateTime.ParseExact(strToDate.Text, "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture);
DateTime date = DateTime.Now;
//Prepare the Insert Command of the DataSource control
string strSQL = "";
strSQL = "INSERT INTO tbl_SShow VALUES ('" + Convert.ToInt32(strTheatreid.SelectedValue) + "','" + Convert.ToInt32(strMovieid.SelectedValue) + "','" + fromdate + "','" + Todate + "','" + date + "','" + date + "')";
SqlDataSource1.InsertCommand = strSQL;
SqlDataSource1.Insert();
ClientScript.RegisterStartupScript(GetType(), "Message", "<SCRIPT LANGUAGE='javascript'>alert('Theatre added successfully');</script>");
//Re bind the grid to refresh the data
GridView1.DataBind();
}
catch (Exception ex)
{
ClientScript.RegisterStartupScript(GetType(), "Message", "<SCRIPT LANGUAGE='javascript'>alert('" + ex.Message.ToString().Replace("'", "") + "');</script>");
}
}
}
//This event occurs on click of the Update button
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
//Get the values stored in the text boxes
string strTheatreid = ((DropDownList)GridView1.Rows[e.RowIndex].FindControl("ddlTheatre")).SelectedValue;
string strMovieid = ((DropDownList)GridView1.Rows[e.RowIndex].FindControl("ddlMovie")).SelectedValue;
string strFromDate = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("txtFromDate")).Text;
string strToDate = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("txtToDate")).Text;
string strShowTimwid = ((Label)GridView1.Rows[e.RowIndex].FindControl("lblShowTimeId")).Text;
try
{
//Prepare the Update Command of the DataSource control
string strSQL = "";
strSQL = "UPDATE tbl_SShow set TheatreId = '" + Convert.ToInt32(strTheatreid) + "'" +
",MovieId = '" + strMovieid + "'" +
",FromDate = '" + strFromDate + "'" +
",ToDate = '" + strToDate + "'" +
" WHERE ShowTimeId = '" + Convert.ToInt32(strShowTimwid) + "'";
SqlDataSource1.UpdateCommand = strSQL;
SqlDataSource1.Update();
ClientScript.RegisterStartupScript(GetType(), "Message", "<SCRIPT LANGUAGE='javascript'>alert('Theatre updated successfully');</script>");
}
catch { }
}
//This event occurs after RowUpdating to catch any constraints while updating
protected void GridView1_RowUpdated(object sender, GridViewUpdatedEventArgs e)
{
//Check if there is any exception while deleting
if (e.Exception != null)
{
ClientScript.RegisterStartupScript(GetType(), "Message", "<SCRIPT LANGUAGE='javascript'>alert('" + e.Exception.Message.ToString().Replace("'", "") + "');</script>");
e.ExceptionHandled = true;
}
}
//This event occurs on click of the Delete button
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
//Get the value
string strShowTimeID = ((Label)GridView1.Rows[e.RowIndex].FindControl("lblShowTimeId")).Text;
//Prepare the delete Command of the DataSource control
string strSQL = "";
try
{
strSQL = "DELETE from tbl_SShow WHERE ShowTimeId = '" + Convert.ToInt32(strShowTimeID) + "'";
SqlDataSource1.DeleteCommand = strSQL;
SqlDataSource1.Delete();
ClientScript.RegisterStartupScript(GetType(), "Message", "<SCRIPT LANGUAGE='javascript'>alert('Theatre deleted successfully');</script>");
}
catch { }
}
//This event occurs after RowDeleting to catch any constraints while deleting
protected void GridView1_RowDeleted(object sender, GridViewDeletedEventArgs e)
{
//Check if there is any exception while deleting
if (e.Exception != null)
{
ClientScript.RegisterStartupScript(GetType(), "Message", "<SCRIPT LANGUAGE='javascript'>alert('" + e.Exception.Message.ToString().Replace("'", "") + "');</script>");
e.ExceptionHandled = true;
}
}
protected void GridView2_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView gvTemp = (GridView)sender;
gvUniqueID = gvTemp.UniqueID;
gvNewPageIndex = e.NewPageIndex;
GridView1.DataBind();
}
protected void GridView2_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "AddShow")
{
try
{
GridView gvTemp = (GridView)sender;
gvUniqueID = gvTemp.UniqueID;
//Get the values stored in the text boxes
string strShowTimeId = gvTemp.DataKeys[0].Value.ToString(); //Customer ID is stored as DataKeyNames
string strShowTime = ((TextBox)gvTemp.FooterRow.FindControl("txtShowTime")).Text;
string strSilver = ((TextBox)gvTemp.FooterRow.FindControl("txtSilver")).Text;
string strGold = ((TextBox)gvTemp.FooterRow.FindControl("txtGold")).Text;
string strPlatinum = ((TextBox)gvTemp.FooterRow.FindControl("txtPlatinum")).Text;
//Prepare the Insert Command of the DataSource control
string strSQL = "";
strSQL = "INSERT INTO tbl_Time VALUES ('" + strShowTime + "','" + strSilver + "','" + strGold + "','" + strPlatinum + "','" + Convert.ToInt32(strShowTimeId) + "')";
SqlDataSource1.InsertCommand = strSQL;
SqlDataSource1.Insert();
ClientScript.RegisterStartupScript(GetType(), "Message", "<SCRIPT LANGUAGE='javascript'>alert('Time added successfully');</script>");
GridView1.DataBind();
}
catch (Exception ex)
{
ClientScript.RegisterStartupScript(GetType(), "Message", "<SCRIPT LANGUAGE='javascript'>alert('" + ex.Message.ToString().Replace("'", "") + "');</script>");
}
}
}
protected void GridView2_RowEditing(object sender, GridViewEditEventArgs e)
{
GridView gvTemp = (GridView)sender;
gvUniqueID = gvTemp.UniqueID;
gvEditIndex = e.NewEditIndex;
GridView1.DataBind();
}
protected void GridView2_CancelingEdit(object sender, GridViewCancelEditEventArgs e)
{
GridView gvTemp = (GridView)sender;
gvUniqueID = gvTemp.UniqueID;
gvEditIndex = -1;
GridView1.DataBind();
}
protected void GridView2_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
try
{
GridView gvTemp = (GridView)sender;
gvUniqueID = gvTemp.UniqueID;
//Get the values stored in the text boxes
string strShowID = ((Label)gvTemp.Rows[e.RowIndex].FindControl("lblShowID")).Text;
string strShowTime = ((TextBox)gvTemp.Rows[e.RowIndex].FindControl("txtShowTime")).Text;
string strSilver = ((TextBox)gvTemp.Rows[e.RowIndex].FindControl("txtSilver")).Text;
string strGold = ((TextBox)gvTemp.Rows[e.RowIndex].FindControl("txtGold")).Text;
string strPlatinum = ((TextBox)gvTemp.Rows[e.RowIndex].FindControl("txtPlatinum")).Text;
//Prepare the Update Command of the DataSource control
SqlDataSource dsTemp = new SqlDataSource();
dsTemp.ConnectionString = ConfigurationManager.ConnectionStrings["MyConn"].ConnectionString.ToString();
string strSQL = "";
strSQL = "UPDATE tbl_Time set ShowTime = '" + strShowTime + "',Silver = '" + strSilver + "' ,Gold = '" + strGold + "',Platinum = '" + strPlatinum + "' WHERE ShowID = '" + strShowID+"' ";
dsTemp.UpdateCommand = strSQL;
dsTemp.Update();
ClientScript.RegisterStartupScript(GetType(), "Message", "<SCRIPT LANGUAGE='javascript'>alert('Order updated successfully');</script>");
//Reset Edit Index
gvEditIndex = -1;
GridView1.DataBind();
}
catch (Exception ex)
{
ClientScript.RegisterStartupScript(GetType(), "Message", "<SCRIPT LANGUAGE='javascript'>alert('" + ex.Message.ToString().Replace("'", "") + "');</script>");
}
}
protected void GridView2_RowUpdated(object sender, GridViewUpdatedEventArgs e)
{
//Check if there is any exception while deleting
if (e.Exception != null)
{
ClientScript.RegisterStartupScript(GetType(), "Message", "<SCRIPT LANGUAGE='javascript'>alert('" + e.Exception.Message.ToString().Replace("'", "") + "');</script>");
e.ExceptionHandled = true;
}
}
protected void GridView2_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
GridView gvTemp = (GridView)sender;
gvUniqueID = gvTemp.UniqueID;
//Get the value
string strShowID = ((Label)gvTemp.Rows[e.RowIndex].FindControl("lblShowID")).Text;
//Prepare the Update Command of the DataSource control
string strSQL = "";
try
{
strSQL = "DELETE from tbl_Time WHERE ShowID = " + strShowID;
SqlDataSource dsTemp = new SqlDataSource();
dsTemp.ConnectionString = ConfigurationManager.ConnectionStrings["MyConn"].ConnectionString.ToString();
dsTemp.DeleteCommand = strSQL;
dsTemp.Delete();
ClientScript.RegisterStartupScript(GetType(), "Message", "<SCRIPT LANGUAGE='javascript'>alert('Show deleted successfully');</script>");
GridView1.DataBind();
}
catch { }
}
protected void GridView2_RowDeleted(object sender, GridViewDeletedEventArgs e)
{
//Check if there is any exception while deleting
if (e.Exception != null)
{
ClientScript.RegisterStartupScript(GetType(), "Message", "<SCRIPT LANGUAGE='javascript'>alert('" + e.Exception.Message.ToString().Replace("'", "") + "');</script>");
e.ExceptionHandled = true;
}
}
protected void GridView2_RowDataBound(object sender, GridViewRowEventArgs e)
{
//Check if this is our Blank Row being databound, if so make the row invisible
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (((DataRowView)e.Row.DataItem)["ShowID"].ToString() == String.Empty) e.Row.Visible = false;
}
}
protected void GridView2_Sorting(object sender, GridViewSortEventArgs e)
{
GridView gvTemp = (GridView)sender;
gvUniqueID = gvTemp.UniqueID;
gvSortExpr = e.SortExpression;
GridView1.DataBind();
}
}
modified 29-Aug-13 4:07am.
|
|
|
|
|
hi where you are getting error is event fired?
|
|
|
|
|
It can't give error but when i insert new record or update record then it is not insert into database or not update in both Gridview.
|
|
|
|
|
Hello Ankit
Please check my code and reply me as soon as possible
Thanks.
|
|
|
|
|
I need an advice regarding the following: No codes
Requirement:
Design a website, with the whole content updatable. I have been given the design, and they want it to look exactly as is – no APS controls. It looks more static. Think Wikipedia without the edit links. – They also don’t want to see the login buttons or link on the website.
The only functionality will be the contact us form.
My Thinking
I will have two identical applications, one for administration and another for the public.
Why Two? Use friendliness: The administrators will have the same look as the public website so they know where to update the website. Think Wikipedia edit links.
Tools:
KnockoutJS- I will learn it in the next 5 days – I am clueless with it, and have 3 weeks to complete the website. I choose it because I will be able to bind the content to the HTML tags, remember, no ASP control on the public Website. I will only be using Knockout for displaying and nothing else.
MVVC – When going through lots of article, I noted that knowledge of MVVC is a required to work with KnockoutJS. I am also clueless in this field. Also to be learnt in the next 5 days.
Would you be so kindly to advise if you think I am taking a proper path and if possible advise on what you would have done without adding tools for me to learn. I do like to learn but not now , except for KnockoutJS and MVVC – I am also maintaining other applications, I will actually be learning during the night.
Current skill/knowledge: C#, ASP.Net, Ajax, SQL, XML, Oracle, HTML, CSS, DevEpress
Thanking you in advance.
I remain joe!
|
|
|
|
|
Am I talking to myself? I think I do.
Planning to study things without having full details about them is not wise.
My expectation about was to be achieved with knockoutjs was wrong, I thought it can connect to SQL and bind the data without additional tools. After going through the book (Knockoutjs_Succinctly), I leant that it’s mainly used for binding data. I know have to lean Json for data manipulation.
So, I ask; will Json be able to communicate with SQL Server?
I know nothing about, I will learn in the next few day. Basic knockout took me a day, so I don’t expect Json to go beyond 3 days.
Advice welcome the path I am talking is welcomed.
Thanking you in advance.
I remain joe!
|
|
|
|
|
JSON won't talk to SQL for you. JSON isn't a language it is just a serialized JavaScript object. If you're using Knockout you will need a webservice you can call (coded in something like .NET perhaps) that will return a JSON object.
|
|
|
|
|
Thanks for the explanation, it helped a lot. I researched a bit following your comment/explanation and now know what to do. I still have to study JSON to at least intermediate level, for now.
Thanks once more, much appreciated.
I remain joe!
|
|
|
|
|
I am designing a asp.net web based form . In which I used 11 panel controls . By Default 4 of them are hidden. Inside the panel control I have created 10R ,6 C layout table . Column 1 and 4 is having texts and 2 and 5th column is haing asp.net control like texbox ,Dropdown list etc .
My problem is I have create css to manage width and color .
But all panels are not align properly however i am using same css class for all .
Please guide .
|
|
|
|
|
Panels or div elements are hard to align, until you understand CSS, and Float. Clear, Display, Block, Inline
If you position 3 div's in a row, then the total width of the 3 div's must not exceed the width of the parent container, or else it will block, block meaning the 3rd div will position down 1 row. Block is the term used in the CSS Display, in which block and inline are valid options.
If you want to stack 3 div's on top of each other, block, then you can use display: block and they will stack in a column.
If you want to create a row of 3 div's, you have to float the 2nd div, and 3rd div to get it to align to the first div.
float: left; display: inline;
It's probably easier to hand assign the CSS for each panel until you get it right, rather that using a class from a CSS File. Then you can get a better idea of how the CSS works for div's.
There use to be a really good tutorial on div alignment but I could not find it. It had picture examples of how to align div elements, or aka panel control in asp.net
http://coding.smashingmagazine.com/2007/05/01/css-float-theory-things-you-should-know/[^]
http://stackoverflow.com/questions/2417130/how-to-align-two-divs-horizontally[^]
modified 4-Aug-13 17:36pm.
|
|
|
|
|
|
Hey,
can any one provide me the help regarding how to retrive the Question and Ans for online quiz model from text file and how can i compare the ans
|
|
|
|
|
Don't use a text file, use a database. There are lots of articles around on this type of application.
Use the best guess
|
|
|
|
|
sir i want to upload file and data to access data base sql and provide solution for that
|
|
|
|
|
Hello,
I need a tool that can be used to write mathematical, chemistry and physics symbols or fomular in my ASP.NET application. The scenario is that, my clients will be solving mathematical, chemistry or physics questions from the ASP.NET application and they will need to write the formular using a tool build in my ASP.NET application to solve any question(from algebra, trigonometry, set theory e.t.c...) in a way they think the answer to the question should be. I am stuck here as I do not know the kind of tool that can be used to accomplish this.
I will be glad to hear a favourable reply on this forum.
Thank You,
|
|
|
|
|
Image compression using half a coding or another.(algorithm)
|
|
|
|
|
You already posted this in the Algorithm forum, and it did not make any sense there either.
Use the best guess
|
|
|
|
|
i am giving some value in textbox1 (take for example vishal). so, when i give tab, it(vishal) should assign in textbox2.
so, i used the following in aspx and java script:
aspx:
onchange="getval()"
javascript
function getval() {
var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
document.getElementById('<%=textbox2.ClientID %>').value = document.getElementById('<%=textbox1.ClientID %>').value;
}
It works correctly in chrome . but, not working in firefox. pls help me out.
|
|
|
|
|
Issue with event keyword. Some browser are not support only "event" keyword. So try to use event called "onblur".
It's opposite of onfocus:
function getval() {
document.getElementById('<%=textbox2.ClientID %>').value = document.getElementById('<%=textbox1.ClientID %>').value;
}
Parwej Ahamad
|
|
|
|
|
rather then change use onkeyup or onkeydown blur will have minimize issues
|
|
|
|
|
Dear All,
I have a table named images in sql server 2008 and it contains two colums imageid and image.Now i am able to insert images in to image column using file uploader controller and image which i have converted to binary form for storing.Now i want to disply the images in a image box correspondance with the image id.I am used textbox for receiving the id and a button to execute the command for displaying.I am using asp.net as front end.
public void ShowImage()
{
SqlConnection con = new SqlConnection();
con.ConnectionString = System.Configuration.ConfigurationManager.AppSettings["anu"].ToString();
SqlCommand cmd = new SqlCommand();
cmd.CommandText = "Select ID,Image from Images where ID=" + txtid.Text;
cmd.CommandType = System.Data.CommandType.Text;
cmd.Connection = con;
con.Open();
SqlDataReader dreader = cmd.ExecuteReader();
dreader.Read();
Context.Response.BinaryWrite((byte[])dreader["image"]);
dreader.Close();
con.Close();
}
This code is working fine but it displaying the picture in a diifrent page but i need to display the picture in the image box which i have added.If anyone who know the answer, please help me.
Regards,
Rajeev K.
|
|
|
|
|