|
you can create a user control contain 5 textboxes and a button
and write a function to deal with under the event of Button_click
|
|
|
|
|
hi iam using asp.net with c#
i have two images imgnew and imagold when i click on browse button i will upload the image and put in imgnew image and the previous image will be in imgold image control it is going fine but when iam closing the application .then again old images are there swap images are not present
can you correct my code where iam going wrong .which helps me
protected void Button1_Click(object sender, EventArgs e)
{ImgOld.Src=ImgNew.Src;
if (FileUpload1.HasFile)
{
FileUpload1.SaveAs(MapPath("~/images/" + FileUpload1.FileName));
ImgNew.Src= "~/images/" + FileUpload1.FileName;
}
}
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="transfer.aspx.cs" Inherits="transfer" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<img id="ImgNew" alt="ImgNew" src="PH02071U.BMP" style="z-index: 102; left: 144px;
width: 144px; position: absolute; top: 104px; height: 200px" runat="server" />
<img id="ImgOld" alt="ImgOld" src="" style="z-index: 103; left: 376px; width: 144px;
position: absolute; top: 112px; height: 184px" runat="server" />
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Style="z-index: 100;
left: 280px; position: absolute; top: 424px" Text="Save" />
<asp:FileUpload ID="FileUpload1" runat="server" Style="z-index: 104; left: 152px;
position: absolute; top: 328px" Width="160px" />
</div>
</form>
</body>
</html
i want what ever i have changed that shoul be present after closing appplication also
|
|
|
|
|
hello
i am new to asp.net i have created on small web project with one datagrid on page and when i drag and drop sql data adapter on page it shows error "Generated SELECT Statment"
and then i have managed to solve this issue but now it showing
"Generated CANCEL Statment"
"Generated UPDATE Statment"
"Generated DELETE Statment"
so i dont know what to do now so I have tried to run the project but it also showing error
Server Error in '/WebApplication3' Application.
--------------------------------------------------------------------------------
Login failed for user 'MACHINE NAME\ASPNET'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: Login failed for use MACHINE NAME\ASPNET'.
Source Error:
Line 59: 'Put user code to initialize the page here
Line 60: If Not Page.IsPostBack Then
Line 61: SqlDataAdapter1.Fill(DataSet11)
Line 62: DataBind()
Line 63:
Source File: c:\inetpub\wwwroot\WebApplication3\WebForm1.aspx.vb Line: 61
Stack Trace:
[SqlException: Login failed for user 'DEEPAK-5WT558AI\ASPNET'.]
System.Data.SqlClient.ConnectionPool.GetConnection(Boolean& isInTransaction) +474
System.Data.SqlClient.SqlConnectionPoolManager.GetPooledConnection(SqlConnectionString options, Boolean& isInTransaction) +372
System.Data.SqlClient.SqlConnection.Open() +384
System.Data.Common.DbDataAdapter.QuietOpen(IDbConnection connection, ConnectionState& originalState) +44
System.Data.Common.DbDataAdapter.FillFromCommand(Object data, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +304
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +77
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet) +38
WebApplication3.WebForm1.Page_Load(Object sender, EventArgs e) in c:\inetpub\wwwroot\WebApplication3\WebForm1.aspx.vb:61
System.Web.UI.Control.OnLoad(EventArgs e)
System.Web.UI.Control.LoadRecursive()
System.Web.UI.Page.ProcessRequestMain()
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.2443; ASP.NET Version:1.1.4322.2443
I AM USING VISUAL STUDIO 2003 WITH SQL SERVER 2008 PRO.
SO NOW I HAVE NO IDEA WHAT TO DO
WAITING FOR YOUR KIND HELP
THANKS
|
|
|
|
|
If your database is using integrated authentication (looks like it from your trace), have you defined the ASPNET user in the database?
|
|
|
|
|
Hello sir
thanks for your rep.
but i dont know how to do it i am still searching on net
waiting for your kind rep.
thanks
|
|
|
|
|
Is this your database? Have you installed it? If not you should the ask the system administrator or whoever created this database to add you (or your aspnet user to the database.
Have you ever connected succesfully to this database? Can you for example use SQL Administrator to browse data?
|
|
|
|
|
hello sir
thanks for your prompt response
currently i have one small assignment to create web project with one page so it should display author table from pubs database into datagrid thats all
so what i have done drag and drop sql data adapter on the web page and went through wizard to complite but at the end of wizard it shows generated error for update, delete and cancle so i dont know what to do with this and when i try to run the project it shows loging error
but if i right click on sql data adapter and select priview data it shows all the data
waiting for your kind help
have a nice time
|
|
|
|
|
Im using windows authentication in asp.net application and it is working fine...
I need to give roles for particular user group..
how do we get the user groups from active directory....
Searched google but i could not find that..
Help me out....
|
|
|
|
|
|
|
In my scenario, I need to group the products based on category. The "main" header has columns Product name, Description, Unit and Unitprice. I am programatically adding "secondary" / "sub" header for each cateogry and list the respective product underneath.
I overrode the render function like this
GridViewRow NewHeader = new GridViewRow(rowIndex + 1, rowIndex + 1, DataControlRowType.Header, DataControlRowState.Normal);
GridView1.Controls[0].Rows.AddAt(rowIndex + 1, NewHeader);
The gridview is created as wished - First appears the main header. And Comes the first sub header followed by the related product rows and then comes the next subheader followed by the corresponding product rows at it goes on.
I want to know how can I access these dynamically created "sub header"s. Gridview1.rows collection has only the data rows and the Gridview1.headerrow has only the default headerr row. Is there a way to access my "sub"header rows?
Thanks
Kit
|
|
|
|
|
sallam 2 all
this is a search query bt i got an exception at column S_No
i.e
Select ROW_NUMBER() OVER(ORDER BY pcpd.Cpt_Code, pcpd.Cpt_Description ASC) AS 'S_No', Provider_Cpt_Plan_Detail_Id, Provider_Cpt_Plan_Id, pcpd.Cpt_Code, isnull(pc.Proc_Description,'') as cpt_description, pcpd.Cpt_Modifier, Non_Facility_Participating_Fee, Non_Facility_Non_Participating_Fee, Facility_Participating_Fee, Facility_Non_Participating_Fee, pcpd.Deleted, pcpd.Created_By, pcpd.Created_Date, pcpd.Modified_By, pcpd.Modified_Date From Provider_Cpt_Plan_Details pcpd left outer join procedures pc on pcpd.Cpt_Code=pc.proc_code Where ORDER BY( pcpd.Cpt_Code, pcpd.Cpt_Description ASC) LIKE '4%' And pcpd.Cpt_Code LIKE '00%' And pcpd.Provider_Cpt_Plan_Id ='100ALLALLALLALLALL' And pcpd.Deleted ='0'
the prob is that i use
Select ROW_NUMBER() OVER(ORDER BY pcpd.Cpt_Code, pcpd.Cpt_Description ASC) AS 'S_No' in select statement im confused what i give in search where clause if i give S_No it gives me error if i give the whole ROW_NUMBER...etc etc it says it is used only in select statement
now it gives me exception Incorrect syntax near the keyword 'ORDER'.
when i used ORDER BY( pcpd.Cpt_Code, pcpd.Cpt_Description ASC) LIKE '4%'
any suggestions what i should do?
|
|
|
|
|
Its better if you post your question in databse section.
|
|
|
|
|
hi iam using asp.net with c#
iam saving two images in database but while retreving only one image is displaying
saving code
==========
protected void Button1_Click(object sender, EventArgs e)
{
if (FileUpload1.HasFile && FileUpload2.HasFile)
{
img1.ImageUrl = imgc.ImageUrl;
img2.ImageUrl = imgo.ImageUrl;
FileUpload1.SaveAs(MapPath("~/images/" + FileUpload1.FileName));
imgc.ImageUrl = "~/images/" + FileUpload1.FileName;
FileUpload2.SaveAs(MapPath("~/images/" + FileUpload2.FileName));
imgo.ImageUrl = "~/images/" + FileUpload2.FileName;
con.Open();
SqlCommand cmd = new SqlCommand("Addimgproc", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@Shop", "Alsafa");
FileInfo imageinfo = new FileInfo(FileUpload1.PostedFile.FileName.Trim());
byte[] content = new byte[imageinfo.Length];
FileStream imagestream = imageinfo.OpenRead();
imagestream.Read(content, 0, content.Length);
imagestream.Close();
FileInfo imageinfo1 = new FileInfo(FileUpload2.PostedFile.FileName.Trim());
byte[] content1 = new byte[imageinfo1.Length];
FileStream imagestream1 = imageinfo1.OpenRead();
imagestream1.Read(content1, 0, content1.Length);
imagestream1.Close();
cmd.Parameters.AddWithValue("@imgc", content);
cmd.Parameters.AddWithValue("@imgo", content1);
cmd.ExecuteNonQuery();
con.Close();
}
}
retreving code
================
protected void Page_Load(object sender, EventArgs e)
{
SqlCommand cmd = new SqlCommand("select imgc,imgo from images where Shop='Alsafa'", con);
con.Open();
SqlDataReader dr = cmd.ExecuteReader();
if (dr.HasRows)
{
while (dr.Read())
{
Response.ContentType = "image/gif";
Response.BinaryWrite((byte[])dr["imgc"]);
Response.BinaryWrite((byte[])dr["imgo"]);
}
}
i want to display both the images from data base side by side but it is displaying only one image
|
|
|
|
|
See Images are calls from img tag to the server. So for each img tag it will receive one Request. You might write the Image bytes directly on the Response stream using Response.BinaryWrite.
So I think you either need to write the images to some location accessible from outside and set the url to the img tags Or you create one HttpHandler for images, and access the individual images from the client and write each image individually to the response.
Abhishek Sur
Don't forget to click "Good Answer" if you like this Solution. Visit My Website-->www.abhisheksur.com
|
|
|
|
|
Please put a break point inside While statement and check what goes wrong. What is the record count ?
Cheers !
Abhijit Jana | MVP
Web Site : abhijitjana.net
Don't forget to click "Good Answer" on the post(s) that helped you.
|
|
|
|
|
Hi all..
I have grid view row commad propery
I can get current index using the follwing
object o = e.CommandArgument;
Int32 rowindex = Convert.ToInt32(o);
but i want to read data from cell
int orgId =Convert.ToInt32(gridClientBasePlan.Rows[rowindex].Cells[0].Text);
This is giving exception how to solve this
|
|
|
|
|
|
I am developing an e-commerce site, as part of my academic project. I want to integrate the Paypal. I am not familiar with it. Can we see and learn about transactions without having money in accounts? I want to simulate the transactions. Is there any option for that??
|
|
|
|
|
|
I have a few web applications that I maintain and I find myself very often writing the same block of code over and over again to bind a GridView to a data source. I'm trying to create a Generic method to handle data binding but I'm having trouble getting it to work with Repeaters and DataLists.
Here is the Generic method I have so far:
public void BindControl<T>(T control, SqlCommand sql) where T : System.Web.UI.WebControls.BaseDataBoundControl
{
cmd = sql;
cn.Open();
SqlDataReader dr = cmd.ExecuteReader();
if (dr.HasRows)
{
control.DataSource = dr;
control.DataBind();
}
dr.Close();
cn.Close();
}
That way I can just define my CommandText then make a call to "BindControls(myGridView, cmd)" instead of retyping this same basic block of code every time I need to bind a grid.
The problem is, this doesn't work with Repeaters or DataLists. The error shown says "There is no implicit reference conversion from 'System.Web.UI.WebControls.Repeater' to 'System.Web.UI.WebControls.BaseDataBoundControl'." I can't seem to find the right base class that is in common with all 3 controls.
For now I have overloaded the method specifically for Repeaters and DataLists, but does anyone know what I could use instead of "BaseDataBoundControl" that would work for all three control types?
- Dave
|
|
|
|
|
Try implementing an Interface.
|
|
|
|
|
I think that might be a little outside of my comfort zone, but I'll do some research on it. It might be a good learning experience if nothing else...
I was really hoping there would be some base class that I had just overlooked that would be inclusive of all three control types...
- Dave
|
|
|
|
|
You must "overload" your method.
In words, you write a method
with the same name several
times each taking differrent
args, something like
public void inABind(Gridview gv, DataSet ds)
{Put you code here}
public void inABind(DropDownList ddl, dataset ds)
{Put you code here}
public void inABind(WhateverControl wc, WhateverDataSource weds)
and on and on like that till
you cover all bases
|
|
|
|
|
That's what I've already done in my current solution. I was just looking for a common interface that would allow me to cover them all in one Generic method...
- Dave
|
|
|
|