Thursday, March 29, 2012
Set datagrid cell enabled to false
Here is my code that I tried:Dim cn As New OleDb.OleDbConnection("Provider=SQLOLEDB.1;Integrated Security=SSPI;" _
& "Persist Security Info=False;" _
& "Initial Catalog=fuel info;" _
& "UID=;PWD=;" _
& "Data Source=Server7")
cn.Open()
Dim datAdapt As New OleDb.OleDbDataAdapter("Select Vendor_No as [Vendor No], " & _
"Vendor_Name as [Vendor Name], Vendor_Terminal as [Vendor Terminal], " & _
"Vendor_Trmnl_No As [Terminal No], Vendor_City As [City], Vendor_State As " & _
"[State], ID From Other_Vendors Order By Vendor_Name", cn)
Dim datSet As New Data.DataSet
datAdapt.Fill(datSet, "Other_Vendors")
DataGrid1.DataSource = datSet
DataGrid1.DataKeyField = "ID"
DataGrid1.EditItemIndex = e.Item.ItemIndex
e.Item.Cells(3).Enabled = False
DataGrid1.DataBind()
cn.Close()
cn.Dispose()
datAdapt.Dispose()
datSet.Dispose()
As you can see, the line that is not working is "e.item.cells(3).enabled = false"
Also, if anyone knows how to set the width of the cell on the fly as well, I would appreciate that as well.
ThanksTry looking into the ItemDataBound sub and adding
e.Item.Cells(3).Enabled = False
in there. You cant disable the cells before the data is in them. RIght now you are trying to disable that cell before the data has been bound to the grid.
Jerel
Phelnglai, that did the trick. One more quick question. Could you set the cell width from the same place? If so, do you know the syntax? Thanks.
What about the cell header? What would the syntax be for that?
Thanks again!
Nevermind, I see that if you just increase the width of the actual datagrid, the fields will increase and adjust on their own at run time.
Glad you got it. Sorry I never answered your second question. I was in a car wreck and am just now getting back to work and doing thinks.
If you have any other questions, feel free to ask.
Jerel
Wednesday, March 28, 2012
Set default button
Enter button this default button is automtcally clicked.
Thanks,
LouIn ASP.NET 2.0 the panel control has a new DefaultButton property.
Set this property to the ID of a button control and it will be the default
button when focus is in that panel.
I hope this helps,
Steve C. Orr,
MCSD, MVP, CSM, ASPInsider
http://SteveOrr.net
"Lou Civitella" <lou@.webersystems.com> wrote in message
news:ucBQh8$PHHA.4492@.TK2MSFTNGP02.phx.gbl...
> How can I set a button as default on an aspx page? When the user hits the
> Enter button this default button is automtcally clicked.
> Thanks,
> Lou
>
Hi,
To your TextBox add a JavaScript event onkeydown using
Attributes.Add().
if pressed key is EnterKey i.e with KeyCode=13 then call the Click()
method of the button(this is the default button)
TextBox1.Attributes.Add("onkeydown", "if(event.keyCode){if
(event.keyCode == 13)
{document.getElementById('"+Button1.UniqueID+"').click();return
false;}} else {return true}; ");
thanks,
aru
Set default button
Enter button this default button is automtcally clicked.
Thanks,
LouIn ASP.NET 2.0 the panel control has a new DefaultButton property.
Set this property to the ID of a button control and it will be the default
button when focus is in that panel.
--
I hope this helps,
Steve C. Orr,
MCSD, MVP, CSM, ASPInsider
http://SteveOrr.net
"Lou Civitella" <lou@.webersystems.comwrote in message
news:ucBQh8$PHHA.4492@.TK2MSFTNGP02.phx.gbl...
Quote:
Originally Posted by
How can I set a button as default on an aspx page? When the user hits the
Enter button this default button is automtcally clicked.
>
Thanks,
Lou
>
Hi,
To your TextBox add a JavaScript event onkeydown using
Attributes.Add().
if pressed key is EnterKey i.e with KeyCode=13 then call the Click()
method of the button(this is the default button)
TextBox1.Attributes.Add("onkeydown", "if(event.keyCode){if
(event.keyCode == 13)
{document.getElementById('"+Button1.UniqueID+"').click();return
false;}} else {return true}; ");
thanks,
aru
Monday, March 26, 2012
Set field to null
How can I set it to DBNull?
I have tried the following but It doesnt work.
You may try this:Dim updateSOrder As String = "Update SOrders set confirm_id = @dotnet.itags.org.confirmId where SOrder ='" & lblConfirmOrder.Text & "'"
Dim SaveDelete As SqlCommand
SaveDelete = New SqlCommand(updateSOrder, oConnection)Dim blank As DBNull
SaveDelete.Parameters.Add(New SqlParameter("@dotnet.itags.org.ConfirmId", SqlDbType.NVarChar, 40))
SaveDelete.Parameters("@dotnet.itags.org.ConfirmId").Value = blankSaveDelete.ExecuteNonQuery()
SaveDelete.Parameters("@.ConfirmId").Value = DBNull.Value