|
I have a datagrid with this definition:
<asp:DataGrid id="CatGrid" runat="server" CssClass="Grid_General" HeaderStyle-CssClass="Grid_Header" ItemStyle-CssClass="Grid_Item" AlternatingItemStyle-CssClass="Grid_AlternatingItem" AllowSorting="True" AutoGenerateColumns="False" DataKeyField="CategoryID" OnEditCommand="CatGrid_Edit" OnCancelCommand="CatGrid_CancelEdit" OnUpdateCommand="CatGrid_Update" OnDeleteCommand="CatGrid_Delete" OnSortCommand="CatGrid_Sort" Width="100%">
<Columns>
<asp:EditCommandColumn ItemStyle-Width="25px" EditText="<img border=0 Alt='Edit this category' src=./Images/Edit.gif>" CancelText="<img border=0 src=./Images/Cancel.gif>" UpdateText="<img border=0 src=./Images/OK.gif>" />
<asp:ButtonColumn ItemStyle-Width="25px" Text="<img border=0 Alt='Delete this category' src=./Images/Delete.gif>" CommandName="delete" />
<asp:BoundColumn HeaderText="ID" HeaderStyle-Font-Bold="True" ItemStyle-Width="30px" DataField="CategoryID" ReadOnly="True" SortExpression="CategoryID" />
<asp:TemplateColumn HeaderText="Name" HeaderStyle-Font-Bold="True" SortExpression="Name" ItemStyle-Width="150px">
<ItemTemplate>
<asp:Label runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "Name") %>' ID="Label1" />
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="EditCatName" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "Name") %>' CssClass="TextBox" Width="150px" />
<asp:RequiredFieldValidator Id="ValidateEditName" runat="server" ControlToValidate="EditCatName" Display="dynamic">* Name is required</asp:RequiredFieldValidator>
</EditItemTemplate>
</asp:TemplateColumn>
.
.
.
</Columns>
</asp:DataGrid>
When user press on first field of first column,that row goes in edited mode and text box appear for that
row,then after he/she change the text there DataGrid1_Update event occur,in that event I put this code:
string strCol2 = ((TextBox)e.Item.FindControl("EditCatName")).Text;
but when I debug the program,the text is not updated and show the previous text.Any idea?
<html><b><FONT face="Lucida Handwriting, Cursive">Mazy</FONT></b></html>
<small><b>"If I go crazy then will you still
Call me Superman
If I’m alive and well, will you be
There holding my hand
I’ll keep you by my side with
My superhuman might
Kryptonite"</b>Kryptonite-3 Doors Down </small>
|
|
|
|
|
I have found the same problem and the solution is to create a TextBox variable, then call the Text function. You can not just cast the control, dont know why. Try:
<br />
TextBox ctrlTextBox = (TextBox)e.Item.FindControl("EditCatName");<br />
string strCol2 = ctrlText.Text.ToString();<br />
You might also wanna double check that FindControl returns a valid control.
Do you know which column you are in? Because you can get it by the following since you are in the UpdateCommand:
<br />
int nColumn = ...;<br />
int nIndex = this.MyDataGrid.EditItemIndex;<br />
TextBox ctrlTextBox = (TextBox)this.MyDataGrid.Items[nIndex].Cells[nColumn].Controls[0];
string strCol2 = ctrlText.Text.ToString();<br />
Hope this helps
|
|
|
|
|
I found the problem.It was about PostBack in Page_Load. Thanks
Mazy
"If I go crazy then will you still
Call me Superman
If I’m alive and well, will you be
There holding my hand
I’ll keep you by my side with
My superhuman might
Kryptonite"Kryptonite-3 Doors Down
|
|
|
|
|
Hello,
Is there any thing available for tab control on client side using jabascript so that I can move from one page to another using the tab controls without going back to the web server for each tab page.
Thanks
Hitesh
|
|
|
|
|
|
How to display messagebox on client machine in asp.net in .aspx.vb file ?
Like in ASP we use the "alert..... " function in html code.
|
|
|
|
|
Anonymous wrote:
How to display messagebox on client machine in asp.net in .aspx.vb file ?
Like in ASP we use the "alert..... " function in html code.
You do it the same way you did it in ASP. Remember alert has nothing to do with ASP, it is a JavaScript method.
|
|
|
|
|
This question caught my eye....
How can you display a messagebox on the clientside in ASP.NET using C#?
I have web page (mypage.aspx and mypage.aspx.cs) with a data grid, when the user tiggers the update command a message is sent to the update function. How can a make a messagebox pop up?
David
|
|
|
|
|
ASP.NET is a serverside technology. You can't use it to popup a message box on the client side. You can only control how the form is rendered tothe browser using C# or VB.
|
|
|
|
|
David Flores wrote:
How can you display a messagebox on the clientside in ASP.NET using C#?
You can't and I never said you could. I was just telling Anonymous that the way you display a messagebox when in the ASP.NET environment is the same way as you did it in and ASP environment. i.e. You return a JavaScript script block back to the client with an alert call in it.
I was thinking that Anonymous thought that ASP.NET would have some fancy new way of doing it, which it doesn't
|
|
|
|
|
Give this statement after the ASP code that does the update.
Response.write(" ALERT('UPDATED');")
Hope it helps
Luv
Pradhip.S
Why Need Parking lots in Bars when Drunken Driving is Prohibited
|
|
|
|
|
Hi,
I'm converting a http form to .aspx and I've managed to change all the fields to controls that will run at the server. However I keep running into a problem, I can't seem to get the user input from the text control.
For example
is my text control
and the user enters some text in it.
I then try and get the text by using
string a= Text1.value
and despite the fact that the user entered the data, a is equal to ""
Thanks for the help!!
|
|
|
|
|
Use
string a = Text1.text
Best regards
Anders
|
|
|
|
|
I tried using the text property but that property doesn't exist for a HttpServerControl.
|
|
|
|
|
this should be simple...i'm trying to set the text part of a file input with some javascript. only it won't do it. the alert below always comes up blank. what am i missing??
here's the html i have:
<input type="file" name="fileImage" value="something1">
and here's the javascript i have:
function image(theForm)
{
var test;
test = "something2";
theForm.fileImage.value = test;
alert(test);
}
thanks!
b
|
|
|
|
|
I hope someone has the answer to this
I have a site in regular old asp 3.0 on IIS 5 -windows 2000.
The site is basically a fancy FTP GUI so users can view files/folders and then download them. What I am trying to do is use the filesystemobject (vbscript) to get a list of the folders/files on a remote data share. I setup the IIS anonymous account to use a domain account instead of IUSER_ComputerName because this domain account has read/write/change permissions on both the IIS box and the data share. Now my problem is that when I run the code below, I am getting an error (not sure what the exact error is)
<br />
'//the UNC path is being pased with URL encoding<br />
ReportPath = Request.QueryString("UNC")<br />
<br />
Set fso = CreateObject("Scripting.FileSystemObject")<br />
'
If fso.FolderExists(ReportPath) Then<br />
Set aFolder = fso.GetFolder(ReportPath)<br />
<br />
For Each aFolder In aFolder.subfolders<br />
.....<br />
Next<br />
Else<br />
errMsg = "Folder/File does not exist or access is denied"<br />
End If<br />
why am I getting this? is it because I am not using a literal for the folder path or because I am not getting authenticated to the remote server?
When I tried this on my local box using VB, it worked fine as long as I didn't use a variable to refer to the UNC path. It may also have worked becuase I have a drive mapped to the UNC path.
I did find one or two articles on MSDN, but it is still unclear to me. This article seemed to have the most information...
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnauth/html/dnauth_security.asp
any ideas? I'm so freakin' confused.
|
|
|
|
|
|
it would be helpful to let me know how to return the error instead of yelling at me.
but thanks anyway.
|
|
|
|
|
Sorry, don't get me wrong: I was not yelling at you, I was instructing you on:
1. Put a "On Error Resume Next" just before the line where the error occur.
2. Put a Response.Write("Error: " & Err) just after the line where the error occur.
3. Give me the error number so I can help you further...
My latest articles:
XOR tricks for RAID data protection
Win32 process suspend/resume tool
|
|
|
|
|
no worries.
using err.number - nothing is returned (i get a big fat zero).
here's the revised code
<br />
Set fso = CreateObject("Scripting.FileSystemObject")<br />
on error resume next<br />
If fso.FolderExists(DataShare) Then<br />
Set aFolder = fso.GetFolder(DataShare)<br />
For Each aFolder In aFolder.subfolders<br />
....<br />
Next<br />
Else<br />
sysErr = "Error Number " & err.number & " Error Description: " & err.Description <br />
errMsg = "Folder/File does not exist or access is denied"<br />
End If<br />
<br />
and just in case it matters the variable "DataShare" is equal to "\\servername\sharename\crp\Daily Reports\"
|
|
|
|
|
What is the error?
Also do you have Norton Antivirus with Script Blocking? I had problems with FileSystemObject also untill turned off Script Blocking in AV
Philip Patrick
Web-site: www.stpworks.com
"Two beer or not two beer?" Shakesbeer
|
|
|
|
|
I know that you should be able to do this...
I place my Connection control on the form and set it's properties..
I add a Command control on the form and set the SQL statement I want
I add my DropDowList control, set the dataSource property, set the properties to bind the text in the list and the values behind the text for my selection...
but when I run the form I get a blank dropDownList.
I can do the binding in code but I really don't think that I should have to.. This should work.
Any takers on this one. I am stumped.
|
|
|
|
|
I don't have much experience with using vstudio for webforms, so I don't know how much code it is generating, however, unlike windows forms, webforms cotnrols require an explicit DataBind() call.
If vstudio isn't generating that call, then you will need to write it.
|
|
|
|
|
Ray Cassick wrote:
but when I run the form I get a blank dropDownList.
As Andy said for WebForms you need to specificaly call the bind method when you want it, generally on Page_Load .
So in the Page_Load event put DataBind() bit.
|
|
|
|
|
Ok, I placed a Page.DataBind() in my Page_Load event and now I am getting the following error:
An invalid data source is being used for DropDownList1. A valid data source must implement either IListSource or IEnumerable.
Line 11:
Line 12:
Line 13: <asp:dropdownlist id="DropDownList1" style="Z-INDEX: 101; LEFT: 88px; POSITION: absolute; TOP: 88px" runat="server" width="184px" height="24px" datasource="<%# DataBinder.Eval(OleDbDataAdapter1, "SelectCommand") %>" autopostback="True" datamember="Products" datatextfield="ProductName" datavaluefield="ProductID">
Line 14:
Line 15:
When I attempt to bind the DropDownList, what do I set the data bindings to? I get a dlalog box that has alot of options in it, and I select the OleDbDataAdapter1.
|
|
|
|