|
hi all.,
this is how i inserted images into sql.. and displayed thumbnail in image control..
byte[] img = new byte[FileUpload1.PostedFile.ContentLength];
HttpPostedFile postfile = FileUpload1.PostedFile;
postfile.InputStream.Read(img, 0, (int)FileUpload1.PostedFile.ContentLength);
System.Drawing.Image img12 = System.Drawing.Image.FromStream(FileUpload1.PostedFile.InputStream);
SqlCommand cmd = new SqlCommand("insert into image11 (type,name,length,byte) values(@type,@name,@length,@byte)", cnn);
cmd.Parameters.Add("@type", SqlDbType.VarChar).Value = FileUpload1.PostedFile.ContentType;
cmd.Parameters.Add("@name", SqlDbType.VarChar).Value = FileUpload1.PostedFile.FileName;
cmd.Parameters.Add("@length", SqlDbType.VarChar).Value = FileUpload1.PostedFile.ContentLength;
cmd.Parameters.Add("@byte", SqlDbType.Image, img.Length).Value = img;
cnn.Open();
cmd.ExecuteNonQuery();
cnn.Close();
DataTable dtTemp = new DataTable("TempImage");
dtTemp.Columns.Add("Image", System.Type.GetType("System.Byte[]"));
DataRow dr = dtTemp.NewRow();
dr[0] = img;
dtTemp.Rows.Add(dr);
Session["dt"] = dtTemp;
Image1.ImageUrl = "de.aspx?id=0";
im trying get image to a image control
but im unable to retrive that image from database i tried using handler.ashx
|
|
|
|
|
madhukk wrote: im trying get image to a image control
Did You write code in
madhukk wrote: Image1.ImageUrl = "de.aspx?id=0";
To show the image..!
LatestArticle :Log4Net
Why Do Some People Forget To Mark as Answer .If It Helps.
|
|
|
|
|
Hi Madhukk,
Please visit this site.
http://www.aspsnippets.com/post/2009/02/21/Display-Images-from-Database-using-ASPNet.aspx
Hope this one can help.
Thanks
Hi, Please select Good Question if my answer are fit to your Question.
|
|
|
|
|
In my application.I have used a gridview and in the header of a particular column of that gridview I have used checkbox.In the checkchanged event of the checkbox some database query executes.It is working but the problem is after the page post the checkbox gets unchecked.But I want that the checkbox remain checked.How can it be achieved.
|
|
|
|
|
Are you re-initializing the checkbox when page is posted back...
You should block the initialization inside
if(!IsPostBack) block .
|
|
|
|
|
No i am not initialising it.
And i am also forcefully checked the checkbox before databind method.But still it is not working.
|
|
|
|
|
Hi,
I'm using asp.net2.0
And using MS Application Blocks for DAL.
Now i'm aware about the performance of the application.
Is that DAL is suitable with asp.net 2.0..
Or any dis advatages?
plz let me know
With regrads
|
|
|
|
|
DAL means Data Layer.
We use this just to separate the Data blocks from presentation layer, so that data manipulation could be made easily manageable.
AFAIK, It will not involve any performance issue.
|
|
|
|
|
Hi all,
I am designing my program like this. I am having a text box, button and a grid view on my page. When i entered some value in text box and click on button the value is binding to grid view. In the grid view i am having only one field as Name and option as select. When i click on select i am displaying the corresponding user in the text box. What i need is if i edit the text on the text box and click on the same button again the value should replace the old one.
Example
TextBox -----------
Button
Gridview
Name
Dora select
Xyz Select
When i click on select at xyz i am displaying it in text box. If i would like to replace it with some name like ABC what to do.. Please help me..
|
|
|
|
|
|
Yes ... It is trivial... First of all let me know are you storing the data into database ?
If the data is in the database, just update the value when user clicks on the button after updating the data, and rebind the Gridview to reflect the update.
|
|
|
|
|
How can I show additional button in a gridview cell based on another cell value.I am using asp.net and c#.
I have ON or OFF values in a GridView cell. Based on this value I want to show a button (opposite Toggle (OFF/On) correspondingly) in another cell.
This is my code.
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.Cells[2].Text== "0")
e.Row.Cells[2].Text = "OFF";
else
e.Row.Cells[2].Text = "ON";
}
please help.
Thank You
|
|
|
|
|
Are you looking for UnBound TemplateField ?
Simply add
<asp:TemplateField HeaderText="Mode">
<ItemTemplate>
<asp:Button runat="server"
Text="<%!Convert.ToBoolean(Eval("Toggle")) %>" CommandName="ToggleClick"
CommandArgument='<%#Eval("Toggle") %>/>
</ItemTemplate>
</asp:TemplateField>
and use OnRowCommand to handle this event.
|
|
|
|
|
thanks for the reply,
but there is something wrong with this code.
Can u recheck it plz?
Thank You
|
|
|
|
|
Yes.. Actually I have written this directly.. Not tried out.... Can you let me know what error you are getting ... ?
Well, Eval("field") should be changed with your valid database field ??
Also change the fieldnames according to the datasource you bound to.
|
|
|
|
|
Actually I am using it as a TemplateField. It's value is not coming from database.
what can be the solution?
Thank You.
|
|
|
|
|
Then Just place True / false instead of Eval statement..
|
|
|
|
|
I have written this. theres is some problem. It shows "Convert.ToBoolean(true)".
What is the problem?
<asp:TemplateField HeaderText="Mode">
<ItemTemplate>
<asp:Button runat="server" Text="<%!Convert.ToBoolean(true) %>" CommandName="ToggleClick" CommandArgument=<%#true %>/>
</ItemTemplate>
</asp:TemplateField>
Thank You
|
|
|
|
|
No no.. write this...
<asp:TemplateField HeaderText="Mode">
<ItemTemplate>
<asp:Button runat="server" Text="True" CommandName="ToggleClick" CommandArgument="True" />
</ItemTemplate>
</asp:TemplateField>
In CommandArgument you need to specify what you want to pass to the event generated when button is clicked. I have placed true there, which is not required. Replace appropriate element there (I mean the field which might be dependent on the button)
|
|
|
|
|
Hi..,
i need to fire an event when double clicked on a listbox control.
|
|
|
|
|
|
currently i m using asp.net 2.0 with sqlserver 2000.
here two tables playing the role. Table "A" and "B". 5 records to be inserted into the "A". after 1st record inserted in "A", the autoid has to be used for the "B" table's column value.
Is it possible using TRANSACTION? (i m not using any store procedure or triggers......only simple insertion).. help me
- Karan
|
|
|
|
|
I do not really understand what you what. Do you mean something like this pseudo-code?
begin
start transansaction
insert into a (somevalues)
insert into b (select @@id from [last insert into a])
insert into a (somevalues)
insert into b (select @@id from [last insert into a])
insert into a (somevalues)
insert into b (select @@id from [last insert into a])
insert into a (somevalues)
insert into b (select @@id from [last insert into a])
insert into a (somevalues)
insert into b (select @@id from [last insert into a])
if(anyerror)
rollback()
else
commit()
end
Greetings
Covean
|
|
|
|
|
EXACTLY!! how can i achieve it? is it possible to fetch the autoid? since we using the transaction. so once all the process are ok, then only it will get commit.... help me.
|
|
|
|
|