|
It depends on how you handle paging. Ideally, your gridview will request the current page of data, and therefore ask for the data for the newly requested page when you change pages. If you have 10,000 items, and 10 per page, would you want to hold 10,000 items in viewstate ?
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillionOneHundredAndFortySevenMillionFourHundredAndEightyThreeThousandSixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it )
|
|
|
|
|
So I know what u're saying but my problem just wasn't that. The scenario is as follows: the user requests the page with a get variable which is a file name, I download a file from a database, get specific entries out of it and store that collection in session state; if the user changes the page I get out the entries from session state, and that's it. What I didn't know is that I have to bind the datasource each time to the gridview and furthermore I realised that I have to bind it again when the event occurs, otherwise it won't work properly.
So I just wanted to say what i've already learned from a short examination.
Thanks for your suggestion, happy coding!
|
|
|
|
|
I have one master page which has various link buttons. OnPostbackURL event of link button I am loading new page. On click of link button the page is getting refreshed. I don't want page refreshment. I tried using 'update panel'. But upadate panel is not supported in ' Contentplace holder '.
The code for the master page.
<asp:updatepanel id="UpdatePanel1" runat="server" updatemode="Conditional">
<contenttemplate>
|
The new page code
<asp:content id="Content1" contentplaceholderid="ContentPlaceHolder1" runat="Server">
| <%--Panel Manage Category--%>
<asp:panel id="panCategory" runat="server" height="26px" width="165px" cssclass="padheading">
Manage Category <asp:imagebutton id="ibtnCategory" runat="server" height="19px" imageurl="~/Images/arrow1.jpg"
style="position: relative" width="20px" causesvalidation="False">
| <%--Panel Category Items---%>
<asp:panel id="panCategoryItem" runat="server" height="69px" style="position: relative;" width="165px">
<asp:linkbutton id="lnkAddCategory" cssclass="text" runat="server" style="position:relative;" postbackurl="CreateCategory.aspx" enabletheming="True" borderstyle="None" causesvalidation="False">Create Category
| <asp:linkbutton id="lnkUpdateCategory" cssclass="text" runat="server" style="position: relative;" postbackurl="CreateCategory.aspx" causesvalidation="False">Edit/Update Category
| <asp:linkbutton id="lnkViewCategory" cssclass="text" runat="server" style="position: relative;" postbackurl="CreateCategory.aspx" causesvalidation="False">View Category
|
|
Category: | | | <asp:label id="lblErrorMessage" runat="server" font-bold="True" forecolor="Red" cssclass="errortext_1"> | Category Name: | <asp:textbox id="txtCategoryName" runat="server" cssclass="textbox_1">
<asp:requiredfieldvalidator id="RequiredFieldValidator1" runat="server" controltovalidate="txtCategoryName"
errormessage="Enter category name" cssclass="errortext_1"> | Category Description: | <asp:textbox id="txtCategoryDescription" runat="server" height="50px" textmode="MultiLine" width="200px" cssclass="textbox_1">
<asp:requiredfieldvalidator id="RequiredFieldValidator2" runat="server" controltovalidate="txtCategoryDescription"
errormessage="Enter category description" cssclass="errortext_1"> | | <asp:button id="btnAddCategory" runat="server" text="Add Category" onclick="btnAddCategory_Click" cssclass="textbox_1">
| View Category: | | Select Type: | <asp:dropdownlist id="ddlCategoryType" runat="server" autopostback="True" onselectedindexchanged="DropDownList1_SelectedIndexChanged" cssclass="textbox_1">
<asp:listitem value="Active">Show Active Categories
<asp:listitem value="InActive">Show InActive Categories
<asp:listitem value="ShowAll">Show All Categories
| | | <asp:gridview id="gdViewCategory" runat="server" onrowediting="gdViewCategory_RowEditing" bordercolor="Black" cellpadding="4" onrowdatabound="gdViewCategory_RowDataBound" borderstyle="Solid" borderwidth="1px" cssclass="text_1" forecolor="#333333" gridlines="None">
<footerstyle backcolor="#5D7B9D" font-bold="True" forecolor="White">
<columns>
<asp:commandfield buttontype="Button" showeditbutton="True">
<rowstyle backcolor="#F7F6F3" forecolor="#333333">
<editrowstyle backcolor="#999999">
<selectedrowstyle backcolor="#E2DED6" font-bold="True" forecolor="#333333">
<pagerstyle backcolor="#284775" forecolor="White" horizontalalign="Center">
<headerstyle backcolor="#5D7B9D" font-bold="True" forecolor="White">
<alternatingrowstyle backcolor="White" forecolor="#284775">
|
Regards;
T h kishore |
|
|
|
|
|
|
hi to all,
I am using asp.net 2.0, in that I designed a webpage for uploading an image. If the user uploads an image it should be automatically change in to thumbnail and it is displayed in that website. I searched in Google but I didn’t get the proper coding for that. So, please help.
jai prakash
|
|
|
|
|
Why have you posted your question again? You only posted your original question 30mins ago.
Don't you know that it is rude to do this? You won't necessarily get an immediate response to your question. This is a free site, so unless you are going to pay someone for advice you should be prepared to wait.
I've answered your first post. Please read it and remember not to double-post in future.
Paul Marfleet
|
|
|
|
|
sorry ya,here after i will not do it.
I cont get a clear idea from that link. Is there any other link for full code. Please help me.
jai
|
|
|
|
|
I gave you the link to the documentation that shows you how to use the Image.GetThumbnailImage method to create a thumbnail image. The other tasks - uploading an image, saving an image to the file system, displaying an image in a web page should be trivial. What is it that you don't understand? There will be plenty of examples on the web to implement these individual tasks if you search for them.
You're not going to find a single article where you can cut-and-paste the code to immediately solve your problem. As a developer, you should be able to apply your problem-solving and research skills to find a solution. It's not going to be handed on a plate to you.
Paul Marfleet
|
|
|
|
|
Hi,
Jai, I have sending you the code from one of my application, please change it accordingly and let me know when done......
And it's only for jpg, and u cna do it for any one.....
protected void Button2_Click(object sender, EventArgs e)
{
string sSavePath;
string sThumbExtension;
int intThumbWidth;
int intThumbHeight;
sSavePath = _Default.fullpath;
sThumbExtension = "_thumb";
intThumbWidth = 160;
intThumbHeight = 120;
// If file field isn’t empty
if (FileUpload1.PostedFile != null)
{
// Check file size (mustn’t be 0)
HttpPostedFile myFile = FileUpload1.PostedFile;
int nFileLen = myFile.ContentLength;
if (nFileLen == 0)
{
lblOutput.Text = "No file was uploaded.";
return;
}
// Check file extension (must be JPG)
if (System.IO.Path.GetExtension(myFile.FileName).ToLower() != ".jpg")
{
lblOutput.Text = "The file must have an extension of JPG";
return;
}
// Read file into a data stream
byte[] myData = new Byte[nFileLen];
myFile.InputStream.Read(myData, 0, nFileLen);
// Make sure a duplicate file doesn’t exist. If it does, keep on appending an
// incremental numeric until it is unique
string sFilename = System.IO.Path.GetFileName(myFile.FileName);
int file_append = 0;
while (System.IO.File.Exists(( (sSavePath + sFilename))))
{
file_append++;
sFilename = System.IO.Path.GetFileNameWithoutExtension(myFile.FileName)
+ file_append.ToString() + ".jpg";
}
// Save the stream to disk
System.IO.FileStream newFile
= new System.IO.FileStream((sSavePath + sFilename),
System.IO.FileMode.Create);
newFile.Write(myData, 0, myData.Length);
newFile.Close();
// Check whether the file is really a JPEG by opening it
System.Drawing.Image.GetThumbnailImageAbort myCallBack =
new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback);
Bitmap myBitmap;
try
{
myBitmap = new Bitmap((sSavePath + sFilename));
// If jpg file is a jpeg, create a thumbnail filename that is unique.
file_append = 0;
string sThumbFile = System.IO.Path.GetFileNameWithoutExtension(myFile.FileName)
+ sThumbExtension + ".jpg";
while (System.IO.File.Exists((sSavePath + sThumbFile)))
{
file_append++;
sThumbFile = System.IO.Path.GetFileNameWithoutExtension(myFile.FileName) +
file_append.ToString() + sThumbExtension + ".jpg";
}
// Save thumbnail and output it onto the webpage
System.Drawing.Image myThumbnail
= myBitmap.GetThumbnailImage(intThumbWidth,
intThumbHeight, myCallBack, IntPtr.Zero);
// myThumbnail.Save((sSavePath + sThumbFile));
Image1.ImageUrl = @"~\" + (string)Session["user_name"].ToString() + @"\" + sSavePath + sFilename; //+ sThumbFile;
//Directory.GetCurrentDirectory() + @"\" + sThumbFile;
// Displaying success information
lblOutput.Text = "File uploaded successfully!";
TextBox3.Text = @"~\" + (string)Session["user_name"].ToString() + @"\" + sSavePath + sFilename;// sThumbFile;
// Destroy objects
myThumbnail.Dispose();
myBitmap.Dispose();
}
catch (ArgumentException errArgument)
{
// The file wasn't a valid jpg file
lblOutput.Text = "The file wasn't a valid jpg file.";
System.IO.File.Delete(sSavePath + sFilename);
}
}
}
public bool ThumbnailCallback()
{
return false;
}
|
|
|
|
|
hi Abhijit Jana,
please send me the html coding also
thanks
jai prakash
|
|
|
|
|
Html, Coding, is very big one becuase , Image uploading is a small part of the page, u can test it using Create a ImageBox, Take a fileupload control and 1 button
put the code in Button_1 Click
{
}
and in outsides....
ThumbnailCallback()
Any query ask me !!!!
|
|
|
|
|
hi Abhijit Jana,
what should i want to give in sThumbExtension = " ";
jai prakash
|
|
|
|
|
Hi jai,
jai aswitha wrote: sThumbExtension = " ";
I have mention sThumbExtension ="_thumbs"
u can give anything....
If you uplaod a file with abhijit.jpg
then its thumbs should be abhijit_thumbs.jpg
is it clear ??? or you want to ask some think different !!!!
|
|
|
|
|
i am also having pblm related to this .can i get this path pls.
|
|
|
|
|
Please check my reply to jai, for the same !!!
|
|
|
|
|
Why? Don't you have the ability to search the forum yourself?
Also, please don't use textspeak. It's really irritating.
Paul Marfleet
|
|
|
|
|
Hi All,
I want to display corresponding ImageButton of the different Products into GridView runtime.
I have maintained one field which holds ImagePath details(locally),but its not the permanent solution,(if the path changes).Reading Images and Storing Images in D/B is not required.
Any help is appreciated.
Hello There
|
|
|
|
|
Why you store imagePath in database?>just store Image name with extention like as image.jpg and give path in code.
for example
<img src='ImageForlder/<%# Eval("ImageName")%>' />
besT reGard
pAthAn
please don't forget to vote on the post that helped you.
|
|
|
|
|
Hi Imran,
First of all,thanks for the reply.My code or the business logic don't want to code the path,images will already be placed in a particular path and it should display retrieving path fom d/b.
One more thing,its actually Image Button.I hope it's clear now.
Regards,
Montu
Hello There
|
|
|
|
|
|
Hi all
I have a problem. Am tring to display data on dropdown list, i have two dropdown list. i'm displaying data on both from database. when the application starts running the first ddl will list out some data. when we select one the second ddl will display data according to that. but here the problem is, when i select one on first ddl, it is automaticaly errasing all the datas.....
i havint given any where clear command. y it ts not displaying. the problem i nly when it is connected to database. i tried a sample, it is working.
plz help me....
|
|
|
|
|
P_Elza wrote: i tried a sample, it is working.
Not sure what this means.
Have you set breakpoints to see what code is executed ? Best guess is that you're setting the data source on postback, which will clear all viewstate. But that doesn't seem to be exactly what you're describing, do you have a code sample ?
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillionOneHundredAndFortySevenMillionFourHundredAndEightyThreeThousandSixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it )
|
|
|
|
|
ya i have set
but its not entering to private void DdlCustomer_SelectedIndexChanged(object sender, System.EventArgs e) even if i change the selection.
Code Sample
<br />
private void Page_Load(object sender, System.EventArgs e)<br />
{<br />
if (!IsPostBack)<br />
{<br />
Production.Add_CustomerToCombo(DdlCustomer,DdlTitle,dgDetailData,SQL_SELECT_CUST_NAME);
}<br />
logintime.Text=System.DateTime.Now.ToLongDateString(); <br />
BtnSave.Visible=false;<br />
}<br />
<br />
<br />
private void DdlCustomer_SelectedIndexChanged(object sender, System.EventArgs e)<br />
{<br />
BtnSave.Visible=true;<br />
DdlTitle.Items.Clear();<br />
DdlTitle.Items.Add(new ListItem("---SELECT---","0"));<br />
<br />
}<br />
|
|
|
|
|
OK, then the combobox isn't set up to handle the event, or it's autopostback is not set to true. And, I still think your viewstate is probably off.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillionOneHundredAndFortySevenMillionFourHundredAndEightyThreeThousandSixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it )
|
|
|
|
|
autopostback is set to true and viewstate is on.
but i didnt get
Christian Graus wrote: combobox isn't set up to handle the event
|
|
|
|
|
Do one thing override the page init method put the code of populating the drop down in that method so it will populate every time regardless of postback
if you don't want to hit the database every time then put all values in session instead and and get vlaues from session or similar to like that
Thanks and Regards
Sandeep
If If you look at what you do not have in life, you don't have anything,
If you look at what you have in life, you have everything... "
|
|
|
|