No I haven't solved this yet. I attached the file, see if it helps...
Thanks. --- Karthick Kumar <[EMAIL PROTECTED]> wrote: > Hey, did you solve this yet?. > > OK, check all your field names, variables etc. has > been supplied > properly.... can't think of any by just looking at > the code... if possible, > send me the file and I will have a look at it... > > Karthick > > > -----Original Message----- > From: Anna Leon [mailto:[EMAIL PROTECTED] > Sent: 01 October 2004 17:47 > To: [EMAIL PROTECTED] > Subject: RE: [AspNetAnyQuestionIsOk] Datagrid Edit > > I am getting an error... > > I've got the template columns, and here's my code to > update: > > ================================================= > Sub dgCoordinator_Update(sender as Object, e as > DataGridCommandEventArgs) > 'update database > 'determine the value of the coordinator id > column > Dim userID as Integer = e.Item.Cells(1).Text > > 'reference each textbox > 'Dim uname as TextBox = > e.Item.Cells(2).Controls(0) > 'Dim pword as TextBox = > e.Item.Cells(3).Controls(0) > 'Dim lname as TextBox = > e.Item.Cells(4).Controls(0) > 'Dim fname as TextBox = > e.Item.Cells(5).Controls(0) > 'Dim email as TextBox = > e.Item.Cells(6).Controls(0) > 'Dim phone as TextBox = > e.Item.Cells(7).Controls(0) > 'Dim regcode as TextBox = > e.Item.Cells(8).Controls(0) > > > Dim uname as string = > CType(e.Item.FindControl("txtUsername"),textbox).Text > Dim pword as string = > CType(e.Item.FindControl("txtPassword"),textbox).Text > Dim lname as string = > CType(e.Item.FindControl("txtLastName"),textbox).Text > Dim fname as string = > CType(e.Item.FindControl("txtFirstName"),textbox).Text > Dim email as string = > CType(e.Item.FindControl("txtEmail"),textbox).Text > Dim phone as string = > CType(e.Item.FindControl("txtPhone"),textbox).Text > Dim regcode as string = > CType(e.Item.FindControl("txtRegionCode"),textbox).Text > > > UpdateCoordinator(userID, uname, pword, lname, > fname, email, phone, regcode) > > dgCoordinator.EditItemIndex = -1 > > > dgCoordinator.DataSource = GetCoordinator(lname, > fname) > dgCoordinator.DataBind() > > Label1.Text = "Record has been updated." > > End Sub > =========================================== > But here's my error, what did I do wrong? > > ================================================== > Object reference not set to an instance of an > object. > Description: An unhandled exception occurred during > the execution of the current web request. Please > review the stack trace for more information about > the > error and where it originated in the code. > > Exception Details: System.NullReferenceException: > Object reference not set to an instance of an > object. > > Source Error: > > > Line 71: > Line 72: > Line 73: Dim uname as string = > CType(e.Item.FindControl("txtUsername"),textbox).Text > Line 74: Dim pword as string = > CType(e.Item.FindControl("txtPassword"),textbox).Text > Line 75: Dim lname as string = > CType(e.Item.FindControl("txtLastName"),textbox).Text > > > Source File: G:\10-01-04\editcoordinator2.aspx > Line: 73 > > Stack Trace: > > > [NullReferenceException: Object reference not set to > an instance of an object.] > > ASP.editcoordinator2_aspx.dgCoordinator_Update(Object > sender, DataGridCommandEventArgs e) in > G:\10-01-04\editcoordinator2.aspx:73 > > System.Web.UI.WebControls.DataGrid.OnUpdateCommand(DataGridCommandEventArgs > e) +83 > > System.Web.UI.WebControls.DataGrid.OnBubbleEvent(Object > source, EventArgs e) +499 > System.Web.UI.Control.RaiseBubbleEvent(Object > source, EventArgs args) +26 > > System.Web.UI.WebControls.DataGridItem.OnBubbleEvent(Object > source, EventArgs e) +100 > System.Web.UI.Control.RaiseBubbleEvent(Object > source, EventArgs args) +26 > > System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs > e) +94 > > System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.Rai > sePostBackEvent(String > eventArgument) +115 > > System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler > sourceControl, String eventArgument) +18 > > System.Web.UI.Page.RaisePostBackEvent(NameValueCollection > postData) +138 > System.Web.UI.Page.ProcessRequestMain() +1263 > > > > ==================================================== > > --- Karthick Kumar <[EMAIL PROTECTED]> > wrote: > > > OH, I think UID is your primary key, so leave it > as > > databound and make it > > read only=true if you are displaying it in the > > datagrid.. > > > > Karthick > > > > > > -----Original Message----- > > From: Anna Leon [mailto:[EMAIL PROTECTED] > > Sent: 01 October 2004 16:51 > > To: [EMAIL PROTECTED] > > Subject: RE: [AspNetAnyQuestionIsOk] Datagrid Edit > > > > What about the uid? Change that to a template > column > > too? Or can I leave it as a databound column? > > > > --- Karthick Kumar > <[EMAIL PROTECTED]> > > wrote: > > > > > Hi, > > > > > > > > > > > > It is because you are passing the same values > for > > > the two textboxes and you > > > are taking from the available datagrid [ see in > > > your code: Dim uname as > > > TextBox = e.Item.Cells(2).Controls(0) ] > > > > > > So better try the following: > > > > > > > > > > > > 1. In your datagrid, instead of Databound, > have > > > it as template columns > > > like below: > > > > > > > > > > > > (Replace the DataItem.std with your column, for > > > example DataItem.Username > > > and id as DataItem.txtUsername etc.) > > > > > > > > > > > > ** Note: You got to do this for all the columns > > > which you want to edit ** > > > > > > > > > > > > <asp:TemplateColumn HeaderText="Standard Time"> > > > > > > <ItemTemplate> > > > > > > <asp:Label runat="server" Text='<%# > > > DataBinder.Eval(Container, > > > "DataItem.Std") %>'></asp:Label> > > > > > > </ItemTemplate> > > > > > > <EditItemTemplate> > > > > > > <asp:TextBox runat="server" id="txtStd" > Text='<%# > > > DataBinder.Eval(Container, > > > "DataItem.Std") %>'></asp:TextBox> > > > > > > </EditItemTemplate> > > > > > > </asp:TemplateColumn> > > > > > > > > > > > > 2. And then get the entered updated value in > > your > > > code like this: > > > > > > > > > > > > Dim std As Integer = > > > CType(e.Item.FindControl("txtStd"), > > > TextBox).Text > > > > > > > > > > > > So in your case, it could be like this: > > > > > > > > > > > > Dim uname as string = > > > CType(e.Item.FindControl("txtUsername"), > > > textbox).text > > > > > > > > > > > > Try this and this will certainly work !!. > > > > > > > > > > > > Hth, > > > > > > Karthick > > > > > > > > > > > > > > > > > > [Non-text portions of this message have been > > > removed] > > > > > > > > > > > > > > > > _______________________________ > > Do you Yahoo!? > > Declare Yourself - Register online to vote today! > > http://vote.yahoo.com > > > > > > > > > > Yahoo! Groups Links > > > > > > > > > > > > > > > > > > > > > _______________________________ > Do you Yahoo!? > Declare Yourself - Register online to vote today! > http://vote.yahoo.com > > > > > Yahoo! Groups Links > > > > > > > > __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com [Non-text portions of this message have been removed] ------------------------ Yahoo! Groups Sponsor --------------------~--> $9.95 domain names from Yahoo!. Register anything. http://us.click.yahoo.com/J8kdrA/y20IAA/yQLSAA/saFolB/TM --------------------------------------------------------------------~-> Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/
