470,587 Members | 2,200 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,587 developers. It's quick & easy.

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

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!
Feb 13 '08 #1
2 1895
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

Feb 13 '08 #2
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.
--
aaa
"wi*****@noclient.net" wrote:
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!
Feb 13 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Carlos Albert | last post: by
2 posts views Thread by Steve | last post: by
6 posts views Thread by =?Utf-8?B?UGF1bA==?= | last post: by
3 posts views Thread by =?Utf-8?B?UGF1bA==?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.