Funkymonkey
08-11-2005, 04:36 AM
I have a datagrid which displays info from the database such as Id number Question and answer. The last column in the grid contains an edit link. When the link is clicked the user is redirected to another page.
I want the info for the current record to be displayed on this page. EG if they click the edit button next to record 5, the edit page will bring up the info for record 5.
The HTML for the edit column is:
<asp:HyperLinkColumn DataNavigateUrlField="ID" FormatString="editfaq.aspx?ID={0}" Text="Edit" HeaderText="Answer" />
The page load event code is:
answer = Trim(Request.QueryString("ID"))
SqlDataAdapter1.SelectCommand.CommandText = "SELECT ID, Category, Question, Answer, Keywords, DateAdded, CreatedBy, Status FROM faqlog WHERE ID='" & answer & "'"
SqlDataAdapter1.Fill(DS, "log")
If DS.Tables("log").Rows.Count > 0 Then
Row = DS.Tables("log").Rows(0)
idtext.Text = Row.Item("ID")
CategoryText.Text = Row.Item("Category")
'ETC for all rows
End If
End Sub
My error message is:
Object reference not set to an instance of an object.
Source Error:
SqlDataAdapter1.SelectCommand.CommandText = "SELECT ID, Category, Question, Answer, Keywords, DateAdded, CreatedBy, Status FROM log WHERE ID='" & answer & "'"
Am I missing something?
Thanks loads
I want the info for the current record to be displayed on this page. EG if they click the edit button next to record 5, the edit page will bring up the info for record 5.
The HTML for the edit column is:
<asp:HyperLinkColumn DataNavigateUrlField="ID" FormatString="editfaq.aspx?ID={0}" Text="Edit" HeaderText="Answer" />
The page load event code is:
answer = Trim(Request.QueryString("ID"))
SqlDataAdapter1.SelectCommand.CommandText = "SELECT ID, Category, Question, Answer, Keywords, DateAdded, CreatedBy, Status FROM faqlog WHERE ID='" & answer & "'"
SqlDataAdapter1.Fill(DS, "log")
If DS.Tables("log").Rows.Count > 0 Then
Row = DS.Tables("log").Rows(0)
idtext.Text = Row.Item("ID")
CategoryText.Text = Row.Item("Category")
'ETC for all rows
End If
End Sub
My error message is:
Object reference not set to an instance of an object.
Source Error:
SqlDataAdapter1.SelectCommand.CommandText = "SELECT ID, Category, Question, Answer, Keywords, DateAdded, CreatedBy, Status FROM log WHERE ID='" & answer & "'"
Am I missing something?
Thanks loads