|
table with columns id, username, pwd, active, email
update table tb_staff set active=1 where active=0
how should i give command argument as link id in query..
|
|
|
|
|
How did you bind the repeater control.Have you used #Eval("id") or databinde r.use the same in the linkbutton.
<asp:linkbutton id="lnkbtnactive" text="Active" commandargument='<%#Eval("id")%>' commandname="xxx" runat="server">
at the codebehind ,
Use item command method to get the commandargument(e.commandargument).you can now get the id.Now you can update the table.Why you have written the query in the page itself.Please prefer to write stored procedures.
|
|
|
|
|
now its completely not workin
if (e.CommandName == "act" && e.CommandArgument=="StaffId")
{
DataSet ds = new DataSet();
DataTable dt = new DataTable();
OleDbDataAdapter ad = new OleDbDataAdapter(cm);
ad.Fill(ds, "tb_staff");
dt = ds.Tables["tb_staff"];
foreach (DataRow row in dt.Rows)
{
if (row["Active"].ToString() == "1")
{
SqlCommand cmd = new SqlCommand("update_staff_active", cnn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@StaffId", SqlDbType.Char).Value = "StaffId";
cmd.Parameters.Add("@Active", SqlDbType.Char).Value = "active";
SqlCommand cmd = new SqlCommand("update_staff_active", cnn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@StaffId", SqlDbType.Char).Value = "TextBox1.Text";
cmd.Parameters.Add("@Active", SqlDbType.Char).Value = "TextBox2.Text";
cnn.Open();
cmd.ExecuteNonQuery();
cnn.Close();
}
}
}
procedure
create PROCEDURE [dbo].[update_staff_active]
(
@StaffId int ,
@Active [char]
)
AS
update tb_staff
set
Active=@Active
where
StaffId=@StaffId
|
|
|
|
|
hi,
you will have to find the row no of that row and then use query
|
|
|
|
|
Hi all,
I want to convert my asp.net application to run on trust level "Medium".
How can i configure my application to run in "Medium" trust level.
Which changes in need to do in code? I have made changes trust level
medium in my web.config file. Which changes in need to do?
Thanks
Rahul
People Laugh on me Because i am Different but i Laugh on them
Because they all are same.
|
|
|
|
|
Wow, look what I found[^] !!!
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Hi
I have already gone through that link and make the changes in web.config file as i mentioned in thread. Do i need to change any other changes in code for this one?
Thanks
Rahul
People Laugh on me Because i am Different but i Laugh on them
Because they all are same.
|
|
|
|
|
Yes, Microsoft wrote an article on what you need to do, but they left stuff out, just to make it hard. What makes you think that what Microsoft told you to do in that article is not enough ? Do you have a specific issue ?
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
In my application i had headings in between the grid rows when i export the grid to excel the headings were not displayed i used the code like this
Response.Clear();
Response.Charset = "";
Response.ContentType = "application/vnd.ms-excel";
System.IO.StringWriter stringWrite = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite = new System.Web.UI.HtmlTextWriter(stringWrite);
htmlWrite.WriteLine("<b><font size=5 color=red>" + Heading.ToString() + "</font></b> <b><font size=4 color=blue>TDP IT-Department</font></b>");
//System.Web.UI.WebControls.DataGrid dg = new System.Web.UI.WebControls.DataGrid();
//dg.DataSource = dv.Table;
//dg.DataBind();
gv.RenderControl(htmlWrite);
Response.Write(stringWrite.ToString());
Response.End();
help me out to solve this
|
|
|
|
|
Not shown at all, or just not styled ?
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
not shown at all an empty row is being displayed
i used the code like this to add a row to grid
DataTable dt1 = dv1.ToTable(true, "nDepartmentID", "sDepartmentName");
int i = 2;
// Session["i"] = ds.Tables[0].DefaultView;
for (int m = 0; m <= dt1.Rows.Count - 1; m++)// foreach (DataRow dr in dt1.Rows)
{
DataTable dt = dv1.ToTable("dt", false);
object objCount = dt.Compute("count(nDepartmentID)", "nDepartmentID in (" + int.Parse(dt1.Rows[m]["nDepartmentID"].ToString()) + ")");
if (dt.Rows.Count > 0)
{
GridViewRow gvRow = new GridViewRow(i, 0, DataControlRowType.DataRow, DataControlRowState.Insert);
TableCell tblCell = new TableCell();
//Add Summary Row
tblCell.Text = dt1.Rows[m]["sDepartmentName"].ToString();
tblCell.ColumnSpan = 6;
tblCell.BorderWidth = 2;
tblCell.HorizontalAlign = HorizontalAlign.Left;
tblCell.ForeColor = System.Drawing.Color.Red;
tblCell.Font.Bold = true;
tblCell.Font.Size = 12;
gvRow.Cells.Add(tblCell);
gridView.Controls[0].Controls.AddAt(i, gvRow);
i = i + int.Parse(objCount.ToString()) + 1;
}
}
|
|
|
|
|
use this code.
Dim attachment As String = "attachment; filename=MyFile.xls"
Response.ClearContent()
Response.AddHeader("content-disposition", attachment)
Response.ContentType = "application/ms-excel"
Dim sw As New StringWriter()
Dim htw As New HtmlTextWriter(sw)
Dim frm As New HtmlForm()
GridViewEmployeeRegistrationDetails.Parent.Controls.Add(frm)
frm.Attributes("runat") = "server"
frm.Controls.Add(GridViewEmployeeRegistrationDetails)
frm.RenderControl(htw)
Response.Write(sw.ToString())
Response.End()
Thanks and Regards
Sujit Kr. Mandal
|
|
|
|
|
Dear all, Thank you. I have made it.
modified on Thursday, October 8, 2009 3:37 AM
|
|
|
|
|
Yonathan1111 wrote: Forum: ASP.NET
Subject: TableInsideTableRow [modified]
Sender: Yonathan1111
Date: Thursday, October 8, 2009 1:21 PM
Dear all, Thank you. I have made it.
|
|
|
|
|
what u hv made??????????
Thanks and Regards
Sujit Kr. Mandal
|
|
|
|
|
Hello Sujit Kr.Mandal. I have made a Table that contains for another table inside one of its row. This can help to have a good layout of controls on the displayable page. The page is done with ASP.Net.
|
|
|
|
|
Hii,
I have been using session variables to maintain the session of a particular user accessing the application.
And on logout, i clear out all sessions and redirect it to login page.
But it doesn't work, since with the help of a browsers back button u can still perform all operations on the appication.
I would like to know the best possible solution for logout functionality.
A user after logout should not be able to access the app even through browsers back button.
Aspiring Techie,
Vishnu Nath
|
|
|
|
|
Hi ,
Are you able to preform operation if you go to the page by browser back button even after logout.If yes,it shows that you have not check whether the session expires in each page.
|
|
|
|
|
Could you please elaborate on how can i check for session expiration.
I used to check for session.IsNewSession on each page.
But even that couldn't help,
hence would like to know how can i implement session expiration in every page.
Aspiring Techie,
Vishnu Nath
|
|
|
|
|
Your login should be stored in the session. You don't need to write some code to expire the session in every page, just set the value you check to null, when someone logs out.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Check the session variable is not null in page load of each pages.If null redirect to login page.It will avoid you to perform operations.
|
|
|
|
|
Vishnu Nath wrote: Could you please elaborate on how can i check for session expiration.
I used to check for session.IsNewSession on each page.
if(Session["UserID"] != null)
{
}
else
{
Response.Redirect("Login.aspx");
}
|
|
|
|
|
Abhijit Jana wrote: if(Session["UserID"] != null)
{
//Do Operation
}
else
{
Response.Redirect("Login.aspx");
}
This is only valid if a session for that variable was created and you are checking for its value.
But if someone requests this page directly, it will throw an error stating
Object refrence not set.
Aspiring Techie,
Vishnu Nath
|
|
|
|
|
|
Buy a really basic book and read it. The code is CHECKING if the value is null.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|