W
wubin_98
Hi All,
Could any expert point out what is wrong in my code?
I search around but couldn't found answer. It seems that I am the first
person have this problem. Thanks in advanced
I have a gridview that one column contains a dropDownList and a
SqlDataSource control.
I try to set up dropDownList selection by following code.
------------------------------------------------
Protected Sub GridViewCapacity_RowCreated(ByVal sender As Object,
ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles
GridViewCapacity.RowCreated
If (e.Row.RowState And DataControlRowState.Edit) <> 0 OrElse
(e.Row.RowState And DataControlRowState.Insert) <> 0 Then
Dim tmp As DropDownList =
CType(e.Row.FindControl("DropDownListLineSS"), DropDownList)
tmp.DataBind()
If Not
IsNothing(tmp.Items.FindByValue(DataBinder.Eval(e.Row.DataItem,
"DropDownListLineSS").ToString())) Then
tmp.SelectedValue = DataBinder.Eval(e.Row.DataItem,
"AssignedLineSS").ToString()
End If
End If
End Sub
------------------------------------------------
Following error message was displayed when execute line "
tmp.DataBind() "
The SqlDataSource control 'SqlDataSourceLineSS' does not have a naming
container. Ensure that the control is added to the page before calling
DataBind.
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.Web.HttpException: The SqlDataSource control
'SqlDataSourceLineSS' does not have a naming container. Ensure that
the control is added to the page before calling DataBind.
Source Error:
Line 50: 'DropDownListLineSS
Line 51: tmp =
CType(e.Row.FindControl("DropDownListLineSS"), DropDownList)
Line 52: tmp.DataBind()
Line 53:
Line 54: If Not
IsNothing(tmp.Items.FindByValue(DataBinder.Eval(e.Row.DataItem,
"DropDownListLineSS").ToString())) Then
Source File: C:\Work\WIP\EditCapacityData.aspx.vb Line: 52
Could any expert point out what is wrong in my code?
I search around but couldn't found answer. It seems that I am the first
person have this problem. Thanks in advanced
I have a gridview that one column contains a dropDownList and a
SqlDataSource control.
I try to set up dropDownList selection by following code.
------------------------------------------------
Protected Sub GridViewCapacity_RowCreated(ByVal sender As Object,
ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles
GridViewCapacity.RowCreated
If (e.Row.RowState And DataControlRowState.Edit) <> 0 OrElse
(e.Row.RowState And DataControlRowState.Insert) <> 0 Then
Dim tmp As DropDownList =
CType(e.Row.FindControl("DropDownListLineSS"), DropDownList)
tmp.DataBind()
If Not
IsNothing(tmp.Items.FindByValue(DataBinder.Eval(e.Row.DataItem,
"DropDownListLineSS").ToString())) Then
tmp.SelectedValue = DataBinder.Eval(e.Row.DataItem,
"AssignedLineSS").ToString()
End If
End If
End Sub
------------------------------------------------
Following error message was displayed when execute line "
tmp.DataBind() "
The SqlDataSource control 'SqlDataSourceLineSS' does not have a naming
container. Ensure that the control is added to the page before calling
DataBind.
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.Web.HttpException: The SqlDataSource control
'SqlDataSourceLineSS' does not have a naming container. Ensure that
the control is added to the page before calling DataBind.
Source Error:
Line 50: 'DropDownListLineSS
Line 51: tmp =
CType(e.Row.FindControl("DropDownListLineSS"), DropDownList)
Line 52: tmp.DataBind()
Line 53:
Line 54: If Not
IsNothing(tmp.Items.FindByValue(DataBinder.Eval(e.Row.DataItem,
"DropDownListLineSS").ToString())) Then
Source File: C:\Work\WIP\EditCapacityData.aspx.vb Line: 52