Click here to Skip to main content
16,005,241 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: how to apply css to my asp.net page Pin
kulandaivel_mca20077-Feb-09 0:06
kulandaivel_mca20077-Feb-09 0:06 
AnswerRe: how to apply css to my asp.net page Pin
Ranjit Viswakumar7-Feb-09 11:30
Ranjit Viswakumar7-Feb-09 11:30 
AnswerRe: how to apply css to my asp.net page Pin
sepel9-Feb-09 4:55
sepel9-Feb-09 4:55 
GeneralMy boss want me to shift my web applications to ASP.NET2005 Pin
Subin Alex6-Feb-09 21:46
Subin Alex6-Feb-09 21:46 
GeneralRe: My boss want me to shift my web applications to ASP.NET2005 Pin
Christian Graus6-Feb-09 23:15
protectorChristian Graus6-Feb-09 23:15 
GeneralRe: My boss want me to shift my web applications to ASP.NET2005 Pin
ziwez07-Feb-09 7:18
ziwez07-Feb-09 7:18 
GeneralRe: My boss want me to shift my web applications to ASP.NET2005 Pin
Ranjit Viswakumar7-Feb-09 12:14
Ranjit Viswakumar7-Feb-09 12:14 
QuestionUnable to bind datagrid item to vb variable Pin
_HawkeyeD6-Feb-09 19:46
_HawkeyeD6-Feb-09 19:46 
Hello everyone, I am having a bit of a problem with my asp.net code (vb). I am attempting to update a datagrid on my page. This is something I have already completed in a previous page. The only difference here that I can tell is that I have made the datagrid on this problem page an updatable datagrid without putting each row into edit mode (using textboxes instead of labels).

When I attempt to assign the values of my datagrid into my vb code I am getting that dreaded "Object reference not set to an instance of an object."

The assignment sits inside a for each. Yet if I pull it out and put it outside the for each (just to see if it will fail again) I receive the same error message. I am stumped. I can't figure out why it works on one asp page, but not this one.

Here is my code. Hopefully someone will be able to help me. P.S. This is for an school project and I am quite new to ASP (about 2 wks new Smile | :) )

Thank you in advance.


<br />
<div style="text-align: center; background-color: lightgrey;"><br />
		<br /><br />
		<br />
		<asp:checkboxlist id="chkFocusSearch" runat="server" autopostback="false" repeatdirection="Horizontal" xmlns:asp="#unknown"><br />
								DataValueField="tid" DataTextField="Type_" Width="360px" >            <br />
		</asp:checkboxlist><br />
		<br />
		<asp:button id="btnSlctAll" runat="server" onclick="btnSlctAll_Click" text="Selet All" xmlns:asp="#unknown"><br />
						Width="114px" /> <br />
						<br />
		<asp:button id="btnSlctNone" runat="server" text="Select None"><br />
						Width="114px" OnClick="btnSlctNone_Click" /> <br />
		<br />
		<asp:button id="btnRefresh" runat="server" text="Refresh View" onclick="RefreshInv" /> <br />
		<br />
		<asp:datagrid id="mysqlInvGrid" runat="server" cellpadding="4" forecolor="#333333" showfooter="True" bordercolor="Black"><br />
                          OnItemCommand="Update"<br />
                          AutoGenerateColumns ="False" BorderWidth="8px" CellSpacing="3" style="border-right: black thin solid; border-top: black thin solid; border-left: black thin solid; border-bottom: black thin solid" Height="299px" Width="360px"><br />
      			<br />
				<columns><br />
					<asp:boundcolumn datafield="prodid" visible="false" /><br />
					<asp:boundcolumn datafield="item" headertext="Item" /><br />
					<br />
					<asp:templatecolumn visible="False"><br />
						<itemtemplate><br />
							<asp:label id="aspProdID" runat="server" text="<%# DataBinder.Eval(Container.DataItem, "prodid") %>" /><br />
						</itemtemplate>	<br />
					</asp:templatecolumn><br />
					<br />
									<br />
					<asp:templatecolumn headertext="Quantity"><br />
					<br />
						<footertemplate><br />
							<asp:button id="btnUpdate" runat="server" text="Update" /><br />
						</footertemplate><br />
					<br />
						<itemtemplate><br />
							<asp:textbox id="aspAmount" runat="server" columns="5" text="<%# Container.DataItem("amount") %>" /><br />
						</itemtemplate><br />
					</asp:templatecolumn><br />
				<br />
					<asp:boundcolumn datafield="measure" headertext="Measurement" /><br />
					<br />
									<br />
				</columns><br />
</asp:datagrid></asp:button></asp:button></div>


<br />
Sub Update(ByVal Sender As Object, ByVal e As DataGridCommandEventArgs)<br />
		Dim dgI As DataGridItem<br />
		Dim strSql As String<br />
		Dim sqlCmd As New MySqlCommand<br />
		<br />
		sqlCmd = New MySqlCommand()<br />
		mysqlConn = DBConnect.Connect<br />
		sqlCmd.Connection = mysqlConn<br />
		<br />
		Try<br />
		<br />
			For Each dgI In mysqlInvGrid.Items<br />
				'get the Prod ID and the new quantity<br />
				Dim strProdID As String = CType(e.Item.FindControl("aspProdID"), Label).Text<br />
				Dim strQuantity As String = CType(e.Item.FindControl("aspAmount"), TextBox).Text<br />
				<br />
				Dim intProdID As Integer = CInt(strProdID)<br />
				Dim intQuantity As Integer = CInt(strQuantity)<br />
			<br />
				'Update the DB with the information we have gathered.<br />
			<br />
				strSql = "update Inventory set quantity = " & intQuantity & " where prodID = " & intProdID<br />
			<br />
				sqlCmd = New MySqlCommand(strSql, mysqlConn)<br />
				sqlCmd.ExecuteNonQuery()<br />
						<br />
			Next<br />
		Catch ex As MySqlException<br />
			MsgBox("Insert failed", MsgBoxStyle.Exclamation, "Insert Status")<br />
			MsgBox("Error returned was '" & ex.Message, MsgBoxStyle.Information, "Error Message")<br />
			MsgBox("SQL command was: '" & strSql)<br />
        <br />
        <br />
		Catch ex As Exception<br />
            <br />
			MsgBox("Insert failed", MsgBoxStyle.Exclamation, "Insert Status")<br />
			MsgBox("Error returned was '" & ex.Message, MsgBoxStyle.Information, "Error Message")<br />
<br />
		Finally<br />
        <br />
			mysqlConn.Close()<br />
			BindGrid()<br />
			<br />
		End Try<br />
<br />

AnswerRe: Unable to bind datagrid item to vb variable Pin
_HawkeyeD6-Feb-09 20:17
_HawkeyeD6-Feb-09 20:17 
QuestionShowing Error Using Java Script Pin
ais076-Feb-09 19:40
ais076-Feb-09 19:40 
AnswerRe: Showing Error Using Java Script Pin
Perspx6-Feb-09 21:01
Perspx6-Feb-09 21:01 
AnswerRe: Showing Error Using Java Script Pin
Ranjit Viswakumar8-Feb-09 5:48
Ranjit Viswakumar8-Feb-09 5:48 
QuestionLoad Report failed Pin
priyagee6-Feb-09 19:33
priyagee6-Feb-09 19:33 
AnswerRe: Load Report failed Pin
varma suresh6-Feb-09 19:50
varma suresh6-Feb-09 19:50 
GeneralRe: Load Report failed Pin
priyagee7-Feb-09 0:40
priyagee7-Feb-09 0:40 
Questionplz help me, i am new to web designing with asp.net and C# Pin
be_humble6-Feb-09 18:07
be_humble6-Feb-09 18:07 
AnswerRe: plz help me, i am new to web designing with asp.net and C# Pin
Christian Graus6-Feb-09 18:10
protectorChristian Graus6-Feb-09 18:10 
AnswerRe: plz help me, i am new to web designing with asp.net and C# Pin
MacSpudster9-Feb-09 9:27
professionalMacSpudster9-Feb-09 9:27 
QuestionAsp.net Gridview header [modified] Pin
SreejithKumar M6-Feb-09 18:04
SreejithKumar M6-Feb-09 18:04 
AnswerRe: Asp.net Gridview header Pin
Christian Graus6-Feb-09 18:15
protectorChristian Graus6-Feb-09 18:15 
GeneralRe: Asp.net Gridview header Pin
SreejithKumar M6-Feb-09 18:22
SreejithKumar M6-Feb-09 18:22 
GeneralRe: Asp.net Gridview header Pin
Christian Graus6-Feb-09 18:37
protectorChristian Graus6-Feb-09 18:37 
GeneralRe: Asp.net Gridview header Pin
SreejithKumar M6-Feb-09 18:51
SreejithKumar M6-Feb-09 18:51 
GeneralRe: Asp.net Gridview header Pin
SreejithKumar M6-Feb-09 19:39
SreejithKumar M6-Feb-09 19:39 
AnswerRe: Asp.net Gridview header Pin
varma suresh6-Feb-09 19:46
varma suresh6-Feb-09 19:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.