|
Thanks
this is just what i needed. it works perfectly for what i need
|
|
|
|
|
Hi I have a column that should only allow the user to enter in integer values in the range 0-100. Only integers. How do I do this and where would I need to put the code.
Mr oizo
|
|
|
|
|
<edititemtemplate>
<asp:label id="retailCBEditLbl" text="<%# Convert.ToDouble(DataBinder.Eval(Container.DataItem, "AmexRetailCB")).ToString("C")%>" runat="server">
<asp:textbox id="retailCBEditTxt" runat="server" width="50" text="<%# Convert.ToDouble(DataBinder.Eval(Container.DataItem, "AmexRetailCB")).ToString%>" maxlength="11">
<asp:requiredfieldvalidator id="Req1" runat="server" controltovalidate="retailCBEditTxt" errormessage="You must enter Retail CB amount." display="None">
<asp:regularexpressionvalidator enabled="true" id="RegEx1" runat="server" display="None" controltovalidate="retailCBEditTxt" errormessage="Please enter only numbers in currency format for Retail CB amount." validationexpression="^(-)?\d+(\.\d\d)?$">
Replace the resular expression to an expression that only accepts numeric (^([0-9]*|\d*\d{1}?\d*)$)
To allow only 0-100 use a custome validator just like regex and validate in code behind.
Hope this helps
|
|
|
|
|
<EditItemTemplate>
<asp:Label ID="retailCBEditLbl" Text='<%# Convert.ToDouble(DataBinder.Eval(Container.DataItem, "AmexRetailCB")).ToString("C")%>' Runat="server" /><br />
<asp:textbox id ="retailCBEditTxt" runat="server" width="50" Text='<%# Convert.ToDouble(DataBinder.Eval(Container.DataItem, "AmexRetailCB")).ToString%>' maxlength="11" ></asp:textbox>
<asp:requiredfieldvalidator id="Req1" runat="server" controltovalidate="retailCBEditTxt" errormessage="You must enter Retail CB amount." display="None"></asp:requiredfieldvalidator>
<asp:regularexpressionvalidator enabled="true" id="RegEx1" runat="server" display="None" controltovalidate="retailCBEditTxt" errormessage="Please enter only numbers in currency format for Retail CB amount." validationexpression="^(-)?\d+(\.\d\d)?$" ></asp:regularexpressionvalidator>
</EditItemTemplate>
Sorry about the earlier message, here you go
|
|
|
|
|
Hi,
we use a ListView control in order to show thumbnails. After we add some thumbnails, we need to know which thumbnail(ListViewItem is selected or clicked/selected with the mouse) and for this we use ListView1_SelectedIndexChanged event. To know that, we want to know the slected index of the ListView so we use the .SelectedIndices(0) method, but it gets an exception error as shown below.
Private Sub ListView1_SelectedIndexChanged(ByVal .....)
Dim index as Integer
index = ListView1.SelectedIndices(0)
End Sub
- ex {"InvalidArgument=Value of '0' is not valid for 'index'.
Parameter name: index"} System.Exception
Any idea how to retrieve the index of the selected ListViewItem?
|
|
|
|
|
You first have to check if SelectedIndices contains anything at all. The SelectedIndexChanged event is also triggered when the previously selected item is unselected, and then no item is selected and the collection is empty.
---
single minded; short sighted; long gone;
|
|
|
|
|
I am having a page1,page2,page3 in a form .in that i am having a controls . I want to save it into .xml file and i want to retrieve the same order of the form and their properties .IS it possible or not through dataset and has to store in .xml file ??
|
|
|
|
|
It's possible to use a DataSet, but you have to populate the DataSet, or any other container, yourself. The ControlsCollection class is not seriablize, not are the controls it contains.
Your code has to examine each control and pick out the properties you want, then save that information in the DataSet or other container.
You might want to check out this blog post[^] for an example of Dynamic Control Creation from an XML file. It does NOT show you how to serialize the controls to make the file though.
Combine what you see in that post with Reflection and XML documents and you should be able to put together a solution. BTW, a DataSet will not help you much.
|
|
|
|
|
Can we get the properties of form Consider controls in xml format for example like this of form controls for multiple pages . or custom properties into xml file using datasets .
<Pages xmlns=""><br />
- <Page PageNo="1"><br />
<PageName>Page1</PageName> <br />
<PageSize>3</PageSize> <br />
<PageOrientation>0</PageOrientation> <br />
<PagePicture /> <br />
<PageNoPicture>false</PageNoPicture> <br />
<PageAllPages>false</PageAllPages> <br />
<PageDesignOnly>false</PageDesignOnly> <br />
- <PageBorder><br />
<BorderLeft>0.75</BorderLeft> <br />
<BorderTop>0.75</BorderTop> <br />
<BorderHeight>0.75</BorderHeight> <br />
<BorderWidth>0.75</BorderWidth> <br />
<BorderPattern>1</BorderPattern> <br />
</PageBorder><br />
- <txt:TextBox TextIndex="1"><br />
<txt:TextName>Text1</txt:TextName> <br />
<txt:TextAlign>0</txt:TextAlign> <br />
<txt:Appearance>1</txt:Appearance> <br />
<txt:TextBackColor>-2147483643</txt:TextBackColor> <br />
<txt:TextForeColor>-2147483640</txt:TextForeColor> <br />
<txt:TextBorderStyle>1</txt:TextBorderStyle> <br />
<txt:TextText>Text1</txt:TextText> <br />
- <fn:Font><br />
<fn:FontName>MS Sans Serif</fn:FontName> <br />
- <fn:FontStyle><br />
<fn:Bold>false</fn:Bold> <br />
<fn:Italic>false</fn:Italic> <br />
</fn:FontStyle><br />
<fn:FontSize>8</fn:FontSize> <br />
<fn:FontUnderline>false</fn:FontUnderline> <br />
<fn:FontStrikeout>false</fn:FontStrikeout> <br />
</fn:Font><br />
<txt:TextToolTip /> <br />
- <pos:Position><br />
<pos:Left>1935</pos:Left> <br />
<pos:Top>1560</pos:Top> <br />
<pos:Height>315</pos:Height> <br />
<pos:Width>1605</pos:Width> <br />
</pos:Position><br />
<txt:TextLocked>false</txt:TextLocked> <br />
<txt:TextMaxLen>255</txt:TextMaxLen> <br />
<txt:TextMinLen>0</txt:TextMinLen> <br />
<txt:TextMultiline>false</txt:TextMultiline> <br />
<txt:TextDataType>0</txt:TextDataType> <br />
<txt:TextFormat /> <br />
<txt:IsIndexField>True</txt:IsIndexField> <br />
</txt:TextBox><br />
- <txt:TextBox TextIndex="2"><br />
<txt:TextName>Text2</txt:TextName> <br />
<txt:TextAlign>0</txt:TextAlign> <br />
<txt:Appearance>1</txt:Appearance> <br />
<txt:TextBackColor>-2147483643</txt:TextBackColor> <br />
<txt:TextForeColor>-2147483640</txt:TextForeColor> <br />
<txt:TextBorderStyle>1</txt:TextBorderStyle> <br />
<txt:TextText>Text2</txt:TextText> <br />
- <fn:Font><br />
<fn:FontName>MS Sans Serif</fn:FontName> <br />
- <fn:FontStyle><br />
<fn:Bold>false</fn:Bold> <br />
<fn:Italic>false</fn:Italic> <br />
</fn:FontStyle><br />
<fn:FontSize>8</fn:FontSize> <br />
<fn:FontUnderline>false</fn:FontUnderline> <br />
<fn:FontStrikeout>false</fn:FontStrikeout> <br />
</fn:Font><br />
<txt:TextToolTip /> <br />
- <pos:Position><br />
<pos:Left>1965</pos:Left> <br />
<pos:Top>2085</pos:Top> <br />
<pos:Height>315</pos:Height> <br />
<pos:Width>1605</pos:Width> <br />
</pos:Position><br />
<txt:TextLocked>false</txt:TextLocked> <br />
<txt:TextMaxLen>255</txt:TextMaxLen> <br />
<txt:TextMinLen>0</txt:TextMinLen> <br />
<br />
<txt:TextFormat /> <br />
<txt:IsIndexField>False</txt:IsIndexField> <br />
</txt:TextBox><br />
- <txt:TextBox TextIndex="3"><br />
<txt:TextName>Text3</txt:TextName> <br />
<txt:TextAlign>0</txt:TextAlign> <br />
<txt:Appearance>1</txt:Appearance> <br />
<txt:TextBackColor>-2147483643</txt:TextBackColor> <br />
<br />
<txt:TextBorderStyle>1</txt:TextBorderStyle> <br />
<txt:TextText>Text3</txt:TextText> <br />
- <fn:Font><br />
<fn:FontName>MS Sans Serif</fn:FontName> <br />
- <fn:FontStyle><br />
<fn:Bold>false</fn:Bold> <br />
<fn:Italic>false</fn:Italic> <br />
<br />
- <pos:Position><br />
<pos:Left>2925</pos:Left> <br />
<pos:Top>4935</pos:Top> <br />
<pos:Height>315</pos:Height> <br />
<pos:Width>1605</pos:Width> <br />
</pos:Position><br />
<txt:TextLocked>false</txt:TextLocked> <br />
<txt:TextMaxLen>255</txt:TextMaxLen> <br />
<txt:TextMinLen>0</txt:TextMinLen> <br />
<txt:TextMultiline>false</txt:TextMultiline> <br />
<txt:TextDataType>0</txt:TextDataType> <br />
<txt:TextFormat /> <br />
<txt:IsIndexField>True</txt:IsIndexField> <br />
</txt:TextBox><br />
- <chk:CheckBox ChkBoxIndex="1"><br />
<chk:ChkBoxName>Checkbox1</chk:ChkBoxName> <br />
<chk:ChkBoxAlign>0</chk:ChkBoxAlign> <br />
<chk:ChkBoxAppearance>1</chk:ChkBoxAppearance> <br />
<chk:ChkBoxBackColor>16777215</chk:ChkBoxBackColor> <br />
<chk:ChkBoxCaption>Checkbox1</chk:ChkBoxCaption> <br />
- <fn:Font><br />
<fn:FontName>MS Sans Serif</fn:FontName> <br />
- <fn:FontStyle><br />
<fn:Bold>false</fn:Bold> <br />
<fn:Italic>false</fn:Italic> <br />
</fn:FontStyle><br />
<fn:FontSize>8</fn:FontSize> <br />
<fn:FontUnderline>false</fn:FontUnderline> <br />
<fn:FontStrikeout>false</fn:FontStrikeout> <br />
</fn:Font><br />
<chk:ChkBoxForeColor>-2147483630</chk:ChkBoxForeColor> <br />
- <pos:Position><br />
<pos:Left>2280</pos:Left> <br />
<pos:Top>3180</pos:Top> <br />
<pos:Height>285</pos:Height> <br />
<pos:Width>1395</pos:Width> <br />
</pos:Position><br />
<chk:ChkBoxToolTip /> <br />
<chk:ChkBoxDefaultValue>false</chk:ChkBoxDefaultValue> <br />
</chk:CheckBox><br />
</Page><br />
</Pages><br />
</Name>
|
|
|
|
|
You might want to check the little box that says "Ignore HTML tags in this message" before you hit post. Your post is completely unreadable.
But, I think you're question is "Can we get a form to render controls automatically from an XML file??" No. You have to write the code to parse the XML file and create the controls and set the properties one at a time.
|
|
|
|
|
hi
combo box in vb.net 2005 is very confusing
-When i click on combo box i cant click anywhere else in form
- some time it show display member some time value member
-it never work in grid
Plz help me
faisal iqbal ch
|
|
|
|
|
Without seeing the code that setup the ComboBox, it's pretty difficult to tell you what's wrong.
|
|
|
|
|
Hi all,
i am having trouble with the line of code below, both my table and record are variables which is fine, but the problem is that sometimes the VARAddRecord string contains an apostrophe and it causes an error - Syntax error (missing operator) in query expression
VARStr = "INSERT INTO [" & VARaddTable & "] ([Episode]) VALUES ('" & VARaddRecord & "')"
im sure it is simple but im fairly new to vb .net so im unsure on how to get around this
can anyone help please?
thanks
|
|
|
|
|
This is the problem with using string concantenation to build SQL queries. You open yourself up to SQL Injection attacks and you have to write a bunch of extra code to handle all the things a user can do to screw up your query.
Read this article[^] by Colin Angus Mackey and you'll understand why what you're doing is a bad idea.
Convert this to a parameterized query and you'll solve your immediate problem, without writing a ton of code to handle character escapes.
|
|
|
|
|
thank you, i will read through that article
i am not using this anywhere that it would be vulnerable to such an attack though as im only creating this program as a hobby, my main job is networking.
but thank you.
P.S if it is not being used for a business do u think there would be much point in me going to the trouble of securing it again injection attacks?
|
|
|
|
|
There's nothing like learning the correct way to do something, even if you don't think you'll need it.
|
|
|
|
|
eyeball_2003 wrote: f it is not being used for a business do u think there would be much point in me going to the trouble of securing it again injection attacks?
Yes.
1. The problem that you have is so closely linked to sql injections that it's hard to solve it without learning anything about sql injections.
2. Bad code has a tendency to spread. Even if it's not used in a business system now, some part of it might be in the future. "Hmm... Didn't I write some code for that before, that I can just copy and paste into this new system...?"
---
single minded; short sighted; long gone;
|
|
|
|
|
number 2 is a valid point, thank you.
and its always in my best interest to learn the correct way
thanks guys
|
|
|
|
|
To use parmaters in your insert statement use the following approach:
Public Sub SqlCommandPrepare()
Dim id As Integer = 20
Dim desc As String = "myFirstRegion"
Dim rConn As SqlConnection = New SqlConnection("Persist Security Info=False;" & _
"Integrated Security=SSPI;database=northwind;server=mySQLServer")
rConn.Open()
Dim command As SqlCommand = New SqlCommand("", rConn)
' Create and prepare an SQL statement.
command.CommandText = "insert into Region (RegionID, RegionDescription) values (@id, @desc)"
command.Parameters.Add("@id", id)
command.Parameters.Add("@desc", desc)
command.Prepare() ' Calling Prepare after having set the Commandtext and parameters.
command.ExecuteNonQuery()
' Change parameter values and call ExecuteNonQuery.
command.Parameters(0).Value = 21
command.Parameters(1).Value = "mySecondRegion"
command.ExecuteNonQuery()
End Sub
This example was copied from the MSDN website at
http://msdn2.microsoft.com/en-us/library/system.data.sqlclient.sqlcommand.prepare(VS.71).aspx
Matt Melick
|
|
|
|
|
greeting again friends,
i again need your help... as always it's badly needed...
my problem is, when i change the column type into a comboboxcolumn i can only change it from design time..
1.) how to change the columns using datagridview into a
comboboxcolumn at runtime?
2.) how to populate the comboboxcolumn at runtime? from codes...
links/ site/codes are highly appreciated... thank you..
start a new beginning in every ending; thats what life for......
|
|
|
|
|
moomoooomoo wrote: 1.) how to change the columns using datagridview into a
comboboxcolumn at runtime?
Create your own columns instead of relying on the designer to do it for you. You can't "modify" an exsting column. It has to be removed and replaced by one your code creates.
moomoooomoo wrote: 2.) how to populate the comboboxcolumn at runtime? from codes...
That depends on where the data is comming from that your trying to populate it with. Is it from a table in the database?? From a file?? Some data you have hard-coded??
Without further information, this[^] is about the best anyone can tell you.
|
|
|
|
|
the data should come from sql database...
start a new beginning in every ending; thats what life for......
|
|
|
|
|
Create a second DataTable object with the ID's and Data of the items that are going to appear in the ComboBoxColumn. Then create a new DataGridViewComboBoxColumn and bind it to this table.
' Retrieve the data for the combobox
Dim DataForCombo As DataTable = SQLStuff.GetDate()
' Create a new ComboBox column
Dim col As New DataGridViewComboBoxColumn
With col
.HeaderText = "Column Header in DGV"
.DataPropertyName = "ID column name in the table the DGV is showing"
.DataSource = DataForCombo
.ValueMember = "ID column name in DataForCombo table"
.DisplayMember = "Column name for the data shown to the user in the ComboBox"
End With
DataGridView1.Columns.Add(col)
|
|
|
|
|
Hi there, is there any way to find out what language is the user using for his/her input keyboard language?
|
|
|
|
|
Hi,
I have created a small application (which you can download from the link below), which tells you about the system information.
http://www.speedyshare.com/692267716.html[^]
Please do let me know if that was helpful...;)
Gary Bigman.
Software Engineer
ComponentOne LLC
www.componentone.com
|
|
|
|