|
SreejithAchutan wrote: button click event iin asp.net
Button1.Attributes.Add("OnClik","YourJSFunction();");
|
|
|
|
|
mareers wrote: u can't call a java script in a asp button click event
WHY ? You can call a JS function on any button click. See my previous post
|
|
|
|
|
Hi All
I am getting a excpetion when i run my code, it was taken from the below url
http://www.sitepoint.com/article/net-shopping-cart-datatables[^]
I have run the code when there is no code behind page as per the authors page and it runs fine but when i try and recreate the code with a code behind I run into the obj.reference exception can someone please tell me how to correct this error. Code Below
Thanks
<br />
Protected Sub AddToCart(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnAdd.Click<br />
<br />
Dim objDT As System.Data.DataTable<br />
Dim objDR As System.Data.DataRow<br />
<br />
objDT = Session("Cart")<br />
Dim Product = ddlProducts.SelectedItem.Text<br />
Dim blnMatch As Boolean = False<br />
<br />
For Each objDR In objDT.Rows <big><-------this is were the exception occurs!!!!!!</big><br />
If objDR("Product") = Product Then<br />
objDR("Quantity") += txtQuantity.Text<br />
blnMatch = True<br />
Exit For<br />
End If<br />
Next<br />
<br />
If Not blnMatch Then<br />
objDR = objDT.NewRow<br />
objDR("Quantity") = txtQuantity.Text<br />
objDR("Product") = ddlProducts.SelectedItem.Text<br />
objDR("Cost") = Decimal.Parse(ddlProducts.SelectedItem.Value)<br />
objDT.Rows.Add(objDR)<br />
End If<br />
Session("Cart") = objDT<br />
<br />
dg.DataSource = objDT<br />
dg.DataBind()<br />
<br />
lblTotal.Text = "$" & GetItemTotal()<br />
End Sub<br />
|
|
|
|
|
thedom2 wrote: objDT = Session("Cart")
You should check the session is null before assigning to an object. Session will be null, so object won't get reference and throws the specified exception.
|
|
|
|
|
why did it work when there was no code behind form ?
|
|
|
|
|
thedom2 wrote: why did it work when there was no code behind form ?
Means ? It won't work until your session contains a valid DataTable object with rows.
|
|
|
|
|
but the code remains the same from the example on the website the only difference is i have incorporated a code behind file ? so i dont quite understand why it works when there is no code-behind ????
|
|
|
|
|
thedom2 wrote: so i dont quite understand why it works when there is no code-behind ????
See this is not the matter you have code behind or not. I reiterate, it's the problem of session's NULL value. So check session is NULL before proceeding. By the way, where you are assigning value to the session ? I have seen you are assigning value to session after you refer it. To refer a value from session, it needs to be created before
|
|
|
|
|
can you show me please if possible ?
thank you
|
|
|
|
|
Well, you can check NULL in session like
if ( Session["cart"] != NULL )
else
It's a c# code, you can convert into VB.NET, Let me know if it helps
|
|
|
|
|
thanks for youre help sorry for all questions
|
|
|
|
|
|
I have a grid view which contains three columns
1. checkbox
2.Bound Field1
3. BoundField2
what I need is
when I check the checkbox , then BoundField2 in that row should be editable.
|
|
|
|
|
Is it possible to iterate through the items in a GridView using
JavaScript on the client?
Thanks
|
|
|
|
|
Well, a gridview does not exist on the client, it's a table. Yes, you can iterate over it.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Thanks Christian. When I try to do this, it says gridView does not exist.
Am I wrong here?
var Table = document.getElementById(gridViewId);
for(i=0; i< Table.rows.length; i++ )
{
}
I have gridView inside the Panel like below. Do you think it fails because Gridview is inside Panel and table?
<asp:Panel ID="PanelGrid" runat="server" Visible="true">
<table>
<tr> <td> <asp:GridView> </asp:GridView> </td> </tr>
</table>
</asp:Panel>
Thanks
|
|
|
|
|
It depends, what is gridViewId ? The id you assign on the server is not the one used on the client. You need to do something like
var gridViewId = '<%=gridview.ClientID%.';
to create the variable you use to find the element by it's id.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
hi
how can i define a big field in sql that could keep a text with for example 10,000 characters?
thank you.
nobody help you...
you have to help you yourself
and this is success way.
|
|
|
|
|
Use text or ntext data type for the field.
|
|
|
|
|
oh no my friend's
you can't define a ntext or text field with more 4000 bytes
nobody help you...
you have to help you yourself
and this is success way.
|
|
|
|
|
mr.mohsen wrote: you can't define a ntext or text field with more 4000 bytes
You are mistaken.
The limit for text is 2147483647 characters.
The limit for ntext is 1073741823 characters.
---
"Anything that is in the world when you're born is normal and ordinary and is just a natural part of the way the world works. Anything that's invented between when you're fifteen and thirty-five is new and exciting and revolutionary and you can probably get a career in it. Anything invented after you're thirty-five is against the natural order of things."
-- Douglas Adams
|
|
|
|
|
Yes you can. Check the documentation[^].
mr.mohsen wrote: nobody help you...
you have to help you yourself
and this is success way.
Kind of ironic, seeing as you didn't bother to check yourself before posting.
Paul Marfleet
|
|
|
|
|
How can we fully disable the autocomplete feature of browsers for our site ? I mean how to prevent browsers from remembering textbox values.
|
|
|
|
|
When a .net web site starts up, does it load the web.config into memory and just refer to/use that copy, or does it always reload it from disk to retrieve the desired setting?
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
I believe it uses a file watcher to notice when the file is changed, and thus reload it.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|