Gridview only show row button if something was selected and somethinghas been entered??

  • Thread starter Thread starter wildman
  • Start date Start date
W

wildman

I've coded a gridview that has used bound data to determine if I
should show a button on a particular gridview row as follows:

<asp:TemplateField>
<ItemTemplate>
<asp:Button ID="Submit" Text="Test" CommandArgument='<
%#Eval("CNumber") %>' CommandName="Submit" Enabled='<%#
Test(Eval("ProcessId")) %>' runat="server" />
</ItemTemplate>
</asp:TemplateField>

Question is, how can I do the samething, but based on the value of
other columns that are yet to posted?

For example say I have a textbox column and dropdown column in the
grid. I only want the button to be visible if something has been
entered into the textbox and something has been selected on that row.

Thanks for any help or information!
 
Update on this.

I figured I might be able to accomplish this with in the rowcreated
event of the gridview. However, oddly enough, when I test my
dropdown's selected value, it's always showing the default selected
value, regardless of current viewstate value.

Any ideas?



Protected Sub AddPoints_RowCreated(ByVal sender As Object, ByVal e
As System.Web.UI.WebControls.GridViewRowEventArgs) Handles
gridAddPoints.RowCreated
If e.Row.RowType = DataControlRowType.DataRow Then
Dim minutes As String =
CType(e.Row.Cells(4).FindControl("Minutes"),
DropDownList).SelectedValue
If Not minutes = "Enter Minutes" Then
' NEVER TRUE THOUGH I DO SELECT ANOTHER VALUE.
Dim SubmitPoint As Button =
CType(e.Row.Cells(5).Controls(0), Button)
SubmitPoint.Enabled = "True"
End If
End If
End Sub
 
It must be the week for the GridView... You like someone else earlier have
what appears to be a mix of thing you want to do with the grid. I would
suggest that if you have something that is not working you post the code and
that will make life a lot easier for to help you.
 
Back
Top