Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > problem with linbutton in edit mode

Reply
Thread Tools

problem with linbutton in edit mode

 
 
Mark
Guest
Posts: n/a
 
      07-31-2007
Hi,

i want to perform several things (like checking and correcting automatically
the lenght of a multiline textbox in order to avoid Truncate error, removing
automatically "<" and "'" to avoid "potential danger" error etc ..) with
javascript on a gridview.

If i take in the aspx file this:
<asp:CommandField ShowEditButton="True">
i have no possibility to use the OnClientClick property.

So i made some Templatefields like this:
<asp:TemplateField><ItemTemplate>
<asp:LinkButton ID="lb1" runat="server" CommandName="Edit"
></asp:LinkButton>

</ItemTemplate></asp:TemplateField>

<asp:TemplateField><EditItemTemplate>
<asp:LinkButton ID="lb2" runat="server" CommandName="Update"
OnClientClick="myfunction();"></asp:LinkButton>
</EditItemTemplate></asp:TemplateField>

<asp:TemplateField><EditItemTemplate>
<asp:LinkButton ID="lb3" runat="server" CommandName="Cancel"
></asp:LinkButton>

</EditItemTemplate></asp:TemplateField>

My problem is now that the linkbutton "Edit" not only appears in normal
mode, but also in Edit mode, together with "Update" and "Cancel"..

I can make it invisible in code-behind, but then there is still an empty
space or column in the gridview.

Any way to solve this?
Thanks
Mark


 
Reply With Quote
 
 
 
 
Teemu Keiski
Guest
Posts: n/a
 
      07-31-2007
Hi,

couldn't you just set myGrid.Columns(x).Visible = False where x is the index
of the column you wish to hide, when you don't want the LinkButton to be
displayed. That would hide the entire column, not just the control.


--
Teemu Keiski
AspInsider, ASP.NET MVP
http://blogs.aspadvice.com/joteke
http://teemukeiski.net


"Mark" <> wrote in message
news:uLABk$...
> Hi,
>
> i want to perform several things (like checking and correcting
> automatically the lenght of a multiline textbox in order to avoid Truncate
> error, removing automatically "<" and "'" to avoid "potential danger"
> error etc ..) with javascript on a gridview.
>
> If i take in the aspx file this:
> <asp:CommandField ShowEditButton="True">
> i have no possibility to use the OnClientClick property.
>
> So i made some Templatefields like this:
> <asp:TemplateField><ItemTemplate>
> <asp:LinkButton ID="lb1" runat="server" CommandName="Edit"
> ></asp:LinkButton>

> </ItemTemplate></asp:TemplateField>
>
> <asp:TemplateField><EditItemTemplate>
> <asp:LinkButton ID="lb2" runat="server" CommandName="Update"
> OnClientClick="myfunction();"></asp:LinkButton>
> </EditItemTemplate></asp:TemplateField>
>
> <asp:TemplateField><EditItemTemplate>
> <asp:LinkButton ID="lb3" runat="server" CommandName="Cancel"
> ></asp:LinkButton>

> </EditItemTemplate></asp:TemplateField>
>
> My problem is now that the linkbutton "Edit" not only appears in normal
> mode, but also in Edit mode, together with "Update" and "Cancel"..
>
> I can make it invisible in code-behind, but then there is still an empty
> space or column in the gridview.
>
> Any way to solve this?
> Thanks
> Mark
>



 
Reply With Quote
 
 
 
 
Mark
Guest
Posts: n/a
 
      07-31-2007
Hi, thanks for replying.

I tried this:

Protected Sub GridView1_RowCreated(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowCreated
If (e.Row.RowState And DataControlRowState.Edit) = DataControlRowState.Edit
Then
If e.Row.RowType = DataControlRowType.DataRow Then
Dim lb As LinkButton
lb = e.Row.FindControl("lb2")
lb.Visible = False
....

But there is still an empty column in the selected row and "Edit" is shown
in all not selected rows.

I also tried this:
Protected Sub GridView1_RowCreated(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowCreated
If (e.Row.RowState And DataControlRowState.Edit) = DataControlRowState.Edit
Then
GridView1.Columns(1).Visible = False

but this gives the error: Object reference not set to an instance of an
object.


"Teemu Keiski" <> schreef in bericht
news:...
> Hi,
>
> couldn't you just set myGrid.Columns(x).Visible = False where x is the
> index of the column you wish to hide, when you don't want the LinkButton
> to be displayed. That would hide the entire column, not just the control.
>
>
> --
> Teemu Keiski
> AspInsider, ASP.NET MVP
> http://blogs.aspadvice.com/joteke
> http://teemukeiski.net
>
>
> "Mark" <> wrote in message
> news:uLABk$...
>> Hi,
>>
>> i want to perform several things (like checking and correcting
>> automatically the lenght of a multiline textbox in order to avoid
>> Truncate error, removing automatically "<" and "'" to avoid "potential
>> danger" error etc ..) with javascript on a gridview.
>>
>> If i take in the aspx file this:
>> <asp:CommandField ShowEditButton="True">
>> i have no possibility to use the OnClientClick property.
>>
>> So i made some Templatefields like this:
>> <asp:TemplateField><ItemTemplate>
>> <asp:LinkButton ID="lb1" runat="server" CommandName="Edit"
>> ></asp:LinkButton>

>> </ItemTemplate></asp:TemplateField>
>>
>> <asp:TemplateField><EditItemTemplate>
>> <asp:LinkButton ID="lb2" runat="server" CommandName="Update"
>> OnClientClick="myfunction();"></asp:LinkButton>
>> </EditItemTemplate></asp:TemplateField>
>>
>> <asp:TemplateField><EditItemTemplate>
>> <asp:LinkButton ID="lb3" runat="server" CommandName="Cancel"
>> ></asp:LinkButton>

>> </EditItemTemplate></asp:TemplateField>
>>
>> My problem is now that the linkbutton "Edit" not only appears in normal
>> mode, but also in Edit mode, together with "Update" and "Cancel"..
>>
>> I can make it invisible in code-behind, but then there is still an empty
>> space or column in the gridview.
>>
>> Any way to solve this?
>> Thanks
>> Mark
>>

>
>



 
Reply With Quote
 
Teemu Keiski
Guest
Posts: n/a
 
      07-31-2007
Hi,

I think cannot use it until the grid has been databound though not 100%
sure. Try after calling DataBind()

--
Teemu Keiski
AspInsider, ASP.NET MVP
http://blogs.aspadvice.com/joteke
http://teemukeiski.net

..


"Mark" <> wrote in message
news:...
> Hi, thanks for replying.
>
> I tried this:
>
> Protected Sub GridView1_RowCreated(ByVal sender As Object, ByVal e As
> System.Web.UI.WebControls.GridViewRowEventArgs) Handles
> GridView1.RowCreated
> If (e.Row.RowState And DataControlRowState.Edit) =
> DataControlRowState.Edit Then
> If e.Row.RowType = DataControlRowType.DataRow Then
> Dim lb As LinkButton
> lb = e.Row.FindControl("lb2")
> lb.Visible = False
> ...
>
> But there is still an empty column in the selected row and "Edit" is shown
> in all not selected rows.
>
> I also tried this:
> Protected Sub GridView1_RowCreated(ByVal sender As Object, ByVal e As
> System.Web.UI.WebControls.GridViewRowEventArgs) Handles
> GridView1.RowCreated
> If (e.Row.RowState And DataControlRowState.Edit) =
> DataControlRowState.Edit Then
> GridView1.Columns(1).Visible = False
>
> but this gives the error: Object reference not set to an instance of an
> object.
>
>
> "Teemu Keiski" <> schreef in bericht
> news:...
>> Hi,
>>
>> couldn't you just set myGrid.Columns(x).Visible = False where x is the
>> index of the column you wish to hide, when you don't want the LinkButton
>> to be displayed. That would hide the entire column, not just the control.
>>
>>
>> --
>> Teemu Keiski
>> AspInsider, ASP.NET MVP
>> http://blogs.aspadvice.com/joteke
>> http://teemukeiski.net
>>
>>
>> "Mark" <> wrote in message
>> news:uLABk$...
>>> Hi,
>>>
>>> i want to perform several things (like checking and correcting
>>> automatically the lenght of a multiline textbox in order to avoid
>>> Truncate error, removing automatically "<" and "'" to avoid "potential
>>> danger" error etc ..) with javascript on a gridview.
>>>
>>> If i take in the aspx file this:
>>> <asp:CommandField ShowEditButton="True">
>>> i have no possibility to use the OnClientClick property.
>>>
>>> So i made some Templatefields like this:
>>> <asp:TemplateField><ItemTemplate>
>>> <asp:LinkButton ID="lb1" runat="server" CommandName="Edit"
>>> ></asp:LinkButton>
>>> </ItemTemplate></asp:TemplateField>
>>>
>>> <asp:TemplateField><EditItemTemplate>
>>> <asp:LinkButton ID="lb2" runat="server" CommandName="Update"
>>> OnClientClick="myfunction();"></asp:LinkButton>
>>> </EditItemTemplate></asp:TemplateField>
>>>
>>> <asp:TemplateField><EditItemTemplate>
>>> <asp:LinkButton ID="lb3" runat="server" CommandName="Cancel"
>>> ></asp:LinkButton>
>>> </EditItemTemplate></asp:TemplateField>
>>>
>>> My problem is now that the linkbutton "Edit" not only appears in normal
>>> mode, but also in Edit mode, together with "Update" and "Cancel"..
>>>
>>> I can make it invisible in code-behind, but then there is still an empty
>>> space or column in the gridview.
>>>
>>> Any way to solve this?
>>> Thanks
>>> Mark
>>>

>>
>>

>
>



 
Reply With Quote
 
Teemu Keiski
Guest
Posts: n/a
 
      07-31-2007
See: http://fredrik.nsquared2.com/viewpost.aspx?postid=339

E.g try changing cells Visible property but in RowDataBound

--
Teemu Keiski
AspInsider, ASP.NET MVP
http://blogs.aspadvice.com/joteke
http://teemukeiski.net



"Mark" <> wrote in message
news:...
> Hi, thanks for replying.
>
> I tried this:
>
> Protected Sub GridView1_RowCreated(ByVal sender As Object, ByVal e As
> System.Web.UI.WebControls.GridViewRowEventArgs) Handles
> GridView1.RowCreated
> If (e.Row.RowState And DataControlRowState.Edit) =
> DataControlRowState.Edit Then
> If e.Row.RowType = DataControlRowType.DataRow Then
> Dim lb As LinkButton
> lb = e.Row.FindControl("lb2")
> lb.Visible = False
> ...
>
> But there is still an empty column in the selected row and "Edit" is shown
> in all not selected rows.
>
> I also tried this:
> Protected Sub GridView1_RowCreated(ByVal sender As Object, ByVal e As
> System.Web.UI.WebControls.GridViewRowEventArgs) Handles
> GridView1.RowCreated
> If (e.Row.RowState And DataControlRowState.Edit) =
> DataControlRowState.Edit Then
> GridView1.Columns(1).Visible = False
>
> but this gives the error: Object reference not set to an instance of an
> object.
>
>
> "Teemu Keiski" <> schreef in bericht
> news:...
>> Hi,
>>
>> couldn't you just set myGrid.Columns(x).Visible = False where x is the
>> index of the column you wish to hide, when you don't want the LinkButton
>> to be displayed. That would hide the entire column, not just the control.
>>
>>
>> --
>> Teemu Keiski
>> AspInsider, ASP.NET MVP
>> http://blogs.aspadvice.com/joteke
>> http://teemukeiski.net
>>
>>
>> "Mark" <> wrote in message
>> news:uLABk$...
>>> Hi,
>>>
>>> i want to perform several things (like checking and correcting
>>> automatically the lenght of a multiline textbox in order to avoid
>>> Truncate error, removing automatically "<" and "'" to avoid "potential
>>> danger" error etc ..) with javascript on a gridview.
>>>
>>> If i take in the aspx file this:
>>> <asp:CommandField ShowEditButton="True">
>>> i have no possibility to use the OnClientClick property.
>>>
>>> So i made some Templatefields like this:
>>> <asp:TemplateField><ItemTemplate>
>>> <asp:LinkButton ID="lb1" runat="server" CommandName="Edit"
>>> ></asp:LinkButton>
>>> </ItemTemplate></asp:TemplateField>
>>>
>>> <asp:TemplateField><EditItemTemplate>
>>> <asp:LinkButton ID="lb2" runat="server" CommandName="Update"
>>> OnClientClick="myfunction();"></asp:LinkButton>
>>> </EditItemTemplate></asp:TemplateField>
>>>
>>> <asp:TemplateField><EditItemTemplate>
>>> <asp:LinkButton ID="lb3" runat="server" CommandName="Cancel"
>>> ></asp:LinkButton>
>>> </EditItemTemplate></asp:TemplateField>
>>>
>>> My problem is now that the linkbutton "Edit" not only appears in normal
>>> mode, but also in Edit mode, together with "Update" and "Cancel"..
>>>
>>> I can make it invisible in code-behind, but then there is still an empty
>>> space or column in the gridview.
>>>
>>> Any way to solve this?
>>> Thanks
>>> Mark
>>>

>>
>>

>
>



 
Reply With Quote
 
Mark
Guest
Posts: n/a
 
      07-31-2007
I tried this:
Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.GridViewRowEventArgs) Handles
GridView1.RowDataBound
If (e.Row.RowState And DataControlRowState.Edit) =
DataControlRowState.Edit Then
Dim lb As LinkButton
lb = e.Row.FindControl("lb2")
lb.Visible = False
End If
End Sub
but same result: the column is only empty (with a gap) in the selected row.

I also tried this:

Sub GridView1_DataBound doesn't accept the line:
" If (e.Row.RowState And DataControlRowState.Edit) =
DataControlRowState.Edit Then"

It seems to be a though case ...



"Teemu Keiski" <> schreef in bericht
news:...
> See: http://fredrik.nsquared2.com/viewpost.aspx?postid=339
>
> E.g try changing cells Visible property but in RowDataBound
>
> --
> Teemu Keiski
> AspInsider, ASP.NET MVP
> http://blogs.aspadvice.com/joteke
> http://teemukeiski.net
>
>
>
> "Mark" <> wrote in message
> news:...
>> Hi, thanks for replying.
>>
>> I tried this:
>>
>> Protected Sub GridView1_RowCreated(ByVal sender As Object, ByVal e As
>> System.Web.UI.WebControls.GridViewRowEventArgs) Handles
>> GridView1.RowCreated
>> If (e.Row.RowState And DataControlRowState.Edit) =
>> DataControlRowState.Edit Then
>> If e.Row.RowType = DataControlRowType.DataRow Then
>> Dim lb As LinkButton
>> lb = e.Row.FindControl("lb2")
>> lb.Visible = False
>> ...
>>
>> But there is still an empty column in the selected row and "Edit" is
>> shown in all not selected rows.
>>
>> I also tried this:
>> Protected Sub GridView1_RowCreated(ByVal sender As Object, ByVal e As
>> System.Web.UI.WebControls.GridViewRowEventArgs) Handles
>> GridView1.RowCreated
>> If (e.Row.RowState And DataControlRowState.Edit) =
>> DataControlRowState.Edit Then
>> GridView1.Columns(1).Visible = False
>>
>> but this gives the error: Object reference not set to an instance of an
>> object.
>>
>>
>> "Teemu Keiski" <> schreef in bericht
>> news:...
>>> Hi,
>>>
>>> couldn't you just set myGrid.Columns(x).Visible = False where x is the
>>> index of the column you wish to hide, when you don't want the
>>> LinkButton to be displayed. That would hide the entire column, not just
>>> the control.
>>>
>>>
>>> --
>>> Teemu Keiski
>>> AspInsider, ASP.NET MVP
>>> http://blogs.aspadvice.com/joteke
>>> http://teemukeiski.net
>>>
>>>
>>> "Mark" <> wrote in message
>>> news:uLABk$...
>>>> Hi,
>>>>
>>>> i want to perform several things (like checking and correcting
>>>> automatically the lenght of a multiline textbox in order to avoid
>>>> Truncate error, removing automatically "<" and "'" to avoid "potential
>>>> danger" error etc ..) with javascript on a gridview.
>>>>
>>>> If i take in the aspx file this:
>>>> <asp:CommandField ShowEditButton="True">
>>>> i have no possibility to use the OnClientClick property.
>>>>
>>>> So i made some Templatefields like this:
>>>> <asp:TemplateField><ItemTemplate>
>>>> <asp:LinkButton ID="lb1" runat="server" CommandName="Edit"
>>>> ></asp:LinkButton>
>>>> </ItemTemplate></asp:TemplateField>
>>>>
>>>> <asp:TemplateField><EditItemTemplate>
>>>> <asp:LinkButton ID="lb2" runat="server" CommandName="Update"
>>>> OnClientClick="myfunction();"></asp:LinkButton>
>>>> </EditItemTemplate></asp:TemplateField>
>>>>
>>>> <asp:TemplateField><EditItemTemplate>
>>>> <asp:LinkButton ID="lb3" runat="server" CommandName="Cancel"
>>>> ></asp:LinkButton>
>>>> </EditItemTemplate></asp:TemplateField>
>>>>
>>>> My problem is now that the linkbutton "Edit" not only appears in normal
>>>> mode, but also in Edit mode, together with "Update" and "Cancel"..
>>>>
>>>> I can make it invisible in code-behind, but then there is still an
>>>> empty space or column in the gridview.
>>>>
>>>> Any way to solve this?
>>>> Thanks
>>>> Mark
>>>>
>>>
>>>

>>
>>

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Formview dropdownlist won't populate in insert mode, but does in edit mode ??? jobs at webdos ASP .Net Web Controls 0 10-09-2006 03:38 PM
GridView control enters edit mode when I click Edit link twice Jaime Stuardo ASP .Net Web Controls 0 04-07-2006 12:47 AM
Snapshot restraint - edit, edit, edit Alan Browne Digital Photography 24 05-10-2005 10:15 PM
Snapshot restraint - edit, edit, edit Patrick Digital Photography 0 05-06-2005 10:53 PM
Would like to load a datagrid already in edit mode instead of having the user click the edit button Frank Kurka ASP .Net Datagrid Control 8 04-29-2005 09:33 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57