Showing posts with label text. Show all posts
Showing posts with label text. Show all posts

Thursday, March 29, 2012

Please Explain

Hi All

Can anyone help me in understanding the highlighted text please.

For Each row As DataRow In ds.Tables(0).Rows
Dim arr() As Object = row.ItemArray()
For i As Integer = 0 To arr.Length - 1


If arr(i).ToString().IndexOf(",") > 0 Then ' I m unable to get this line of code.


record = record & Chr(34) & arr(i).ToString() & Chr(34) & ","
Else
record = record & arr(i).ToString() & ","
End If
Next
body = body & record.Substring(0, record.Length - 1) & vbCrLf
record = ""
Next

Thanks

Asif Ali.

take the object in Array arr at position indicated by i

convert to a string

find the index (position) of a comma character

see if the comma occurred after the first character position


Hi there

Fantastic explanation..

Thanks Again

Asif.

Please explain what "Empty path has no directory" means with Server.MapPath

Hello,

I have the following line of code in a script...

litMsg.Text = Server.MapPath("/");

where litMsg is an ASP.Net Literal control. When I try and run this
page, I get the error ...

System.ArgumentException: Empty path has no directory.

Anyone any idea what this means? I have used Server.MapPath many times
before without error, I'm not sure why it suddenly stopped working here.

I'm sure I'm missing something blindingly obvious and would be grateful
if anyone could point it out!! TIA.

--
Alan Silver
(anything added below this line is nothing to do with me)IN case it's of any use to anyone, I found out that the problem was
caused by me having the following two lines in Page_Load...

HttpContext myContext = HttpContext.Current;
myContext.RewritePath("/");

I'm not actually sure *why* I had those lines there, they must have been
from something I was doing before. As soon as I removed them, the
Server.MapPath worked fine.

If anyone has an explanation, I would like to hear it ;-)

>Hello,
>I have the following line of code in a script...
>litMsg.Text = Server.MapPath("/");
>where litMsg is an ASP.Net Literal control. When I try and run this
>page, I get the error ...
>System.ArgumentException: Empty path has no directory.
>Anyone any idea what this means? I have used Server.MapPath many times
>before without error, I'm not sure why it suddenly stopped working here.
>I'm sure I'm missing something blindingly obvious and would be grateful
>if anyone could point it out!! TIA.

--
Alan Silver
(anything added below this line is nothing to do with me)

please gimme me a regular expression for date (dd-MMM-yyyy)

please help me as i have to validate a text box for date...check out this site: http://www.regexlib.com/
"pavan" wrote:

Quote:

Originally Posted by

please help me as i have to validate a text box for date...
>
>

Monday, March 26, 2012

Please Help

I was new to visual studio .net and my company task me to do a program where
it will generate a text file into a excel file before that i need to a
program which able to load the text file into database sql. Can any one
possiable helping me solving this problem?Can you please describe your problem with more detail?

Saturday, March 24, 2012

Please Help ! Validation Date ?

How can i validate a valid date when user enter the text into TextBox?Hi,

by using a CompareValidator.


<asp:TextBox ID="txtDate" runat="server" />
<asp:CompareValidator ControlToValidate="txtDate" Operator="DataTypeCheck" Type="Date" ErrorMessage="Please enter a valid date" runat="server" ID="cmpValtxtDate" />

Please Help DDL

I have code that populated a drop down list and with the users selection in the ddl it populates the text fields. This works fine with one exception

The first record in the Drop Down List doesn't populate at all... Please help....I should explain a little better

Here is a snippett from both pages the user selects the item in the drop down menu then they are rerouted to another page than takes that value and populates the textboxes

Private Sub DropDownList1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DropDownList1.SelectedIndexChanged
Dim mystring As String = DropDownList1.SelectedItem.Text
'passing the variable to the next page
Response.Redirect("WebForm2.aspx?mystring=" & DropDownList1.SelectedValue)
End Sub

' this is the second page where it takes that variable and populates the textboxes
'then I am populating the texboxes based on the selectedtext in a fillbox() function

Sub fillBox()
Dim ds As New DataSet

Dim myCommand As OleDbDataAdapter
Dim smyString As String

'retreiving the variable passed from page 1 using the drop down list
smyString = Request.QueryString("mystring")

'code ot take out an apapostrophe
smyString = Replace(smyString, "'", "''")

sql = "Select * From SiteDocNew where [River/Site Name_en] ='" & smyString & "'"
myCommand = New OleDbDataAdapter(sql, conn)

'Fill command to fill the textboxes
myCommand.Fill(ds, "SiteDocNew")
txtLocationDesc.Text = ds.Tables("SiteDocNew").Rows(0).Item("Location & Access Description_en").ToString()
Is the 2nd page not working?
The second page is working with all other records with the exception of the first record on the drop down list.

And if I do click on the first record the second page does not even open...
Sorry I figured it out I just added a null line in the drop down list...

Please help Friends how to control maxlength textbox in datagrid

Is there a way to set the maxlength property for a text box in the datagrid.

My database table field size is only 10 chars for first name.

How can i make the user not to enter more tha 10 chars on the front end.

Is there any Max length property i can assign for the text boxes.

I have 4 text boxes in datagrid.

Thank you very much.Hi,

if it is single-line TextBox, you can use its MaxLength property like you normally can.

<asp:TextBox ID="xxx" MaxLength="4"... /
This works even if TextBox is in a DataGrid.
Thanks Joteke, I have the following code triggered when i click edit in the datagrid, then it will show all text boxes etc. where can i place the maxlength="4" property in the following code.

Thank you very much.

< Code >
Sub MyDataGrid_UpdateCommand(s As Object, e As DataGridCommandEventArgs )
Dim conn As SqlConnection
Dim MyCommand As SqlCommand
Dim strConn as string = "server=Rajender;uid=sa;pwd=sa;database=NORTHWIND"
Dim txtFirstName As textbox = E.Item.cells(2).Controls(0)
Dim txtLastName As textbox = E.Item.cells(3).Controls(0)
Dim txtTitle As textbox = E.Item.cells(4).Controls(0)
Dim strUpdateStmt As String
strUpdateStmt =" UPDATE Employees SET" & _
" FirstName =@.Fname, LastName =@.Lname, Title = @.Title " & _
" WHERE EmployeeID = @.EmpID"
conn = New SqlConnection(strConn)
MyCommand = New SqlCommand(strUpdateStmt, conn)
MyCommand.Parameters.Add(New SQLParameter("@.Fname", txtFirstName.text))
MyCommand.Parameters.Add(New SQLParameter("@.Lname", txtLastName.text))
MyCommand.Parameters.Add(New SQLParameter("@.Title", txtTitle.text))
MyCommand.Parameters.Add(New SQLParameter("@.EmpID", e.Item.Cells(1).Text ))
conn.Open()
MyCommand.ExecuteNonQuery()
MyDataGrid.EditItemIndex = -1
conn.close
BindData
End Sub

</ code >
In that case, you could declare EditItemTemplate for the DataGrid (declaratively in asox) in which you set the TextBox's MaxLength.

If you want to do it programmatically, then you'd do it in ItemDataBound method (when ItemType is EditItem)

Wednesday, March 21, 2012

Please help label text problem

i am new to ASP.net
i am making a form where der are 3 labels
EG. First name
Last name
Password

which have 3 textbox too.. now in labels the text i want it in extreme right.. like in vb.net we have textAlign right, left, center.. Rite

I want to do same in ASP.net i was looking in properties der is nothing like textalign. i tried to write <center> Firstname </center> in the html code(ASP.Net) but code dint work out.. please help me..If you are using an ASP.NET label, just move it to the desired position.
You need to look at an HTML tutorial, you should use DIVs and TABLEs to align your elements as you want.

www.w3schools.com/html
Good point, you should try using DIV's and inserting the desired text, that way you can justify it to the left, center, or right if you want.