|
hi there,
I think you mean that you want the code in block Page_Load not execute when the button is clicked, right? if so, you just put the code into block if(!Page.IsPostBack) , it'll not execute when user clicks the button
Hope this helps...
<< >>
|
|
|
|
|
I'm sure this has been brought up before, but I just can't seem to locate the answer.
I have an internal application that needs to allow access to an admin to manage roles and users on the ASP.Net 2 Website Administration Tool that we all love so much
My question is, is there a way to provide access to this "site" area to someone who is NOT on the local server?
Any help is much appreciated... thanks
|
|
|
|
|
Ok first, I'll outline my project. It is a web application made to search and display records of archived technical documents. What I have right now is a page that uses datagrids (via drag and drop from Visual Studio 2005) to display columns of data from my SQL Test server.
What I need now is a way to create a simple form text box and create and pass a variable to the SELECT statement within the datagrids. All my attempts at this thus far, using both ASP and C# and MSDN knowledgebase, have ended in frustration.
Here is the code of the datagrid:
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
DataSourceID="SqlDataSource1" EmptyDataText="There are no data records to display.">
<Columns>
<asp:BoundField DataField="OVERVIEW" HeaderText=" " SortExpression="OVERVIEW" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="
<%ConnectionStrings:trdConnectionString2 %>"
ProviderName="<%$ ConnectionStrings:trdConnectionString2.ProviderName %>"
SelectCommand="SELECT [OVERVIEW] FROM [SUDS_TRD] WHERE [IDENT]='1'">
</asp:SqlDataSource>
What I need to do is where it says [IDENT]='1', is have that "1" be a parameter passed from an HTML form, perhaps looking like this WHERE [IDENT]='"% strIDENT %"', yet I do not know how to pass a parameter from an HTML form into that SELECT statement. Any help would be great as this is a problem holding up my project.
To reiterate, I need to:
A. create an html form text box
B. pass that textbox as a variable
C. place that variable into the SELECT statement for the ASP datagrid.
Any help would be great, example code, whatever it takes; the simpler the better =) Please just don't send me to MSDN's Datagrid Knowledge Base page as 1/2 the stuff there doesn't even work =[.
Thanks for any help in advance!
Jesse Myse
jessemyer06@aol.com
-- modified at 15:55 Monday 21st August, 2006
|
|
|
|
|
Hi,
You can not pass HTML text box and construct an query dynamically. You should go for server side coding. Imagine there is a button control on click of the control you have to construct the query dynamically based on the values entered on the textbox. So onclick event of the button you can construct the query like,
button1_onclick()
{
string strQuery = "";
strQuery = "Select field1, field2 from table1 where field1 like %'" + textbox1.text.trim() + "%'";
then execute the query with adaptor or something....
}
Ram
|
|
|
|
|
|
Hussein, what's your email address?
Nila Fridley
|
|
|
|
|
Hi
Dear Nila
My email : H_Madani_gh@yahoo.com
Best Regards
Hussein Madani Ghomi
+98-912-5577-832
|
|
|
|
|
|
Hi Guys,
Im in a pickle and I need your help badly.
I have this .net application (2.0) that has many pages, two of which display the 'Page Has Expired' message when the user hits the back button. I tried to remedy this with setting OutputCache to a Duration of 120 seconds, enabled the viewstate in all my controls on those pages... I don't know what else to do. Does anyone have a work around for it?
Thank you -all- in advance!
Nila
|
|
|
|
|
Im writing a website for a company which only wants to provide product information(no prices) and to allow for a customer log in and maintain his/her details.
Wat do you suggest is the best way of displaying customers information allowing for editing(on a personal basis) also?
Thank you
Nothing lasts but nothing is lost
|
|
|
|
|
That is far too vague. It really depends on exactly what you want to do.
Solly74 wrote: Wat do you suggest is the best way of displaying customers information allowing for editing(on a personal basis) also?
With labels and textboxes? I really don't know what you mean by this. What kind of answer were you expecting?
|
|
|
|
|
Well i want the website to allow for the customer to register and login, the customer must be able to view products and its details as well as view and edit his/her details.
Wats the best way of doing this? Because a gridview displays all the customers which is not what i want, i want the customer logged in to only view and edit his/her details..
thank you
Nothing lasts but nothing is lost
|
|
|
|
|
I am trying to create a checklistbox with a button that upon selecting the field they would like to remove from the gridview they click the button and it removes the selected columns. It seems quite easy but I am haveing problems getting this to work. My btn_click event is as follows:
Protected Sub btnUpdate_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Dim li As ListItem
For Each li In CheckBoxList2.Items
If li.Text = "BegAttch" Then
GridView1.Columns(0).Visible = False
Else
GridView1.Columns(0).Visible = True
End If
If li.Text = "Folder" Then
GridView1.Columns(1).Visible = False
Else
GridView1.Columns(1).Visible = True
End If
If li.Text = "DocDate" Then
GridView1.Columns(2).Visible = False
Else
GridView1.Columns(2).Visible = True
End If
End Sub
I have also tried If li.Value = 0 because I set the values to corresponde with the column order.
Any ideas?
PS. I know i should be using a case statement I just want to get it working first.
|
|
|
|
|
I got it. If anyone is interested the code for this is as follows:
Protected Sub btnUpdate_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Dim li As ListItem
For Each li In CheckBoxList2.Items
Select Case li.Value
Case 0
If li.Selected Then
GridView1.Columns(0).Visible = False
Else : GridView1.Columns(0).Visible = True
End If
Case 1
If li.Selected Then
GridView1.Columns(1).Visible = False
Else : GridView1.Columns(1).Visible = True
End If
Case 2
If li.Selected Then
GridView1.Columns(2).Visible = False
Else : GridView1.Columns(2).Visible = True
End If
End Select
Next
End Sub
I am going to update this soon to use a loop to cycle through list items of and columns of unknown amount
|
|
|
|
|
I'm a noob to vb.net & asp.net (I'm using Visual Studio 2003)
I have a webpage that loads a record from the database. The user can then change some of the details and save these back to the datase.
On the page is a sqldataadapter and a dataset which I use to load a datagrid. I can load the page with no problems but I cannot figure out how to save to the database.
I can see where the sqldataadapter has created insert & update commands but cannot figure out how to use them once the page has been loaded. Or maybe thats the point ? - I cant use them *because* the page has been rendered.
I'm getting the feeling that when I want to put data back into the database, I need to start from scratch - eg manually create create a connection string, then create a command, add the parameters, open the connection, execute the query and then close the connection.
Am I thinking in the right direction ?
|
|
|
|
|
What kind of exception are you getting?
Ram
|
|
|
|
|
I'm not geting any exception - I dont have any code at all!
Do you have an example that you could share with me ?
|
|
|
|
|
Hi,
I am really having problems with excel/asp.net coding lately.
I am struggling to get the range from a worksheet in an excel workbook.
Basically the client uploads an excel spreadsheet to our server, and then we have an application that converts that code to a mdb/sql database, depending on what the client wants.
To get to the problem. Currently we tell the client what to call the specific range, with in a sheet (eg 'InvoiceData'), and from that we use a asp.net datasource(OLEDB) that connects to that sheet, retrieve the info we want, and then do whatever is requested with that info.
The problem now is, the client needs to call that range just what they want, and I need to access that range, to do as discussed above. There will only be one range per sheet.
Anyone who can help?
Thanks
|
|
|
|
|
Could you modify your upload form, giving the user an extra text box to enter the range name as well as upload the file?
|
|
|
|
|
Mike Ellison wrote: Could you modify your upload form, giving the user an extra text box to enter the range name as well as upload the file?
Hi Mike,
Yes, I will be able to do that, but not sure how I will be able to use this info, to select the range, or create a range? Any help on that?
|
|
|
|
|
Hi there. Wouldn't it be pretty much the same as what you're doing now? You have code now that expects a specific range name, yes? Why not just substitute a variable name for that part of the code, incorporating the name entered by the user?
|
|
|
|
|
HI,
Yes, you might have a point there. The only problem there might be, is that the use might not enter the range in correctly. I can cater for something like "sheet1$A1:K24", but I am concerned that once this work, there might be a possibility that more tables might be added per worksheet.... thus, using a range a client specifies, might not always be a safe option.
Also, some of the clients might not be that bright with excel, so I would like to cater for someone that just learned excel, and defining a range in excel, is much easier then telling the user to give me the range. Or what do you think?
|
|
|
|
|
Have you considered using a pre-made excel template? Something you would create and distribute to users, that could be locked (except for the range you want them to input)? If multiple tables may be necessary, you could include a button on the sheet to create a second sheet, also with cells locked (except for the input range again). Then your code could loop through the individual sheets and pull the range you're expecting to see...
We've used something like this for an internal survey application. We had the template survey.xls available for download by clicking an icon... users filled it out, then submitted it through an upload form. The template was predefinined to make it easier to work with on the server-end, and to limit the kinds of mistakes users could make.
Just a thought.
|
|
|
|
|
Problem,
To create a navigation menu that can be pulled into multiple pages, one that can change menu button imageurls (for up and down pressed buttons) and one that can access the page its pulled into or be given two values. (person type and person) Here what I have so far:
Create a control, either static or dynamic, something like below
<code<asp hyperlink id="GoPerson_View" runat="server">
then use the page name to determine if the button should be pressed down
Dim PageName As String = HttpContext.Current.Request.Path.ToString<br />
If PageName.Contains("Person_View") Then<br />
GoPerson_View.ImageUrl = "~/images/buttons/Person_View_Down.jpg"<br />
Else<br />
GoPerson_View.ImageUrl = "~/images/buttons/Person_View.jpg"<br />
End If
then i just need to assign the navigation properties
<br />
GoPerson_View.NavigateUrl = "~/Person_View.aspx?pid=" & PersonSelect.SelectedValue & "&fid=" & PersonTypeSelect.SelectedValue<br />
The issue being, without this code being on every page, and the controls too, i cannot get it to update properly if the personselect and persontypeselect values change (these are a list box and drop down list on each page).
this is becoming a major task to update each time a new page is being added. How do i get all this code into a central location.
-- modified at 14:03 Monday 21st August, 2006
|
|
|
|
|
i added an object data source to my form and i have written classes in my app_code.
when i configure the object data source there are no options to select for an object.
can u tell me wat the problem is please?
thank you
Nothing lasts but nothing is lost
|
|
|
|