column in dataGrid

S

simon

I have template column in dataGrid and visible=false.

<asp:TemplateColumn visible=false>
<ItemTemplate><asp:CheckBox Runat=server ID=chkExists Checked='<%# Container.DataItem( "obstaja" ) % >'></asp:CheckBox>
</ItemTemplate>
</asp:TemplateColumn>

When user clicks link button in dataGrid I check the chkExists value:

Private Sub dgdAdvert_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles dgdAdvert.ItemCommand

If e.CommandName = "AdvName" Then
exists = CType(e.Item.Cells(5).Controls(0), CheckBox).Checked
...
...
end if
end sub
If exists=true then I disable some fields for update.

If I have <asp:TemplateColumn visible=false> then exists is always false.

If I have <asp:TemplateColumn visible=true> then it works fine, exists is true or false.

But I don't want that user see the template column, I have it only for checking the exists value.


Where is the problem?

Thank you,

Simon
 
R

Rick Spiewak

If a column has visible = false then it isn't rendered at all. Maybe you can bind the enabled property of your update controls to a column which you create in your datatable (assuming that this is what is bound to the datagrid). Set the value of the item in the column accordingly.
I have template column in dataGrid and visible=false.

<asp:TemplateColumn visible=false>
<ItemTemplate><asp:CheckBox Runat=server ID=chkExists Checked='<%# Container.DataItem( "obstaja" ) % >'></asp:CheckBox>
</ItemTemplate>
</asp:TemplateColumn>

When user clicks link button in dataGrid I check the chkExists value:

Private Sub dgdAdvert_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles dgdAdvert.ItemCommand

If e.CommandName = "AdvName" Then
exists = CType(e.Item.Cells(5).Controls(0), CheckBox).Checked
...
...
end if
end sub
If exists=true then I disable some fields for update.

If I have <asp:TemplateColumn visible=false> then exists is always false.

If I have <asp:TemplateColumn visible=true> then it works fine, exists is true or false.

But I don't want that user see the template column, I have it only for checking the exists value.


Where is the problem?

Thank you,

Simon
 
S

simon

I use the same update controls also for inserts.
When user click the update, I enable/disable them regarding to the chkExists column,
If user clicks INSERT, I enable all controls.
So I need somehow to know, if the row exists or not.
I thought I could solve this by template column and checkBox and visible=false.

Is there any other solution?

Thank you,
Simon
If a column has visible = false then it isn't rendered at all. Maybe you can bind the enabled property of your update controls to a column which you create in your datatable (assuming that this is what is bound to the datagrid). Set the value of the item in the column accordingly.
I have template column in dataGrid and visible=false.

<asp:TemplateColumn visible=false>
<ItemTemplate><asp:CheckBox Runat=server ID=chkExists Checked='<%# Container.DataItem( "obstaja" ) % >'></asp:CheckBox>
</ItemTemplate>
</asp:TemplateColumn>

When user clicks link button in dataGrid I check the chkExists value:

Private Sub dgdAdvert_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles dgdAdvert.ItemCommand

If e.CommandName = "AdvName" Then
exists = CType(e.Item.Cells(5).Controls(0), CheckBox).Checked
...
...
end if
end sub
If exists=true then I disable some fields for update.

If I have <asp:TemplateColumn visible=false> then exists is always false.

If I have <asp:TemplateColumn visible=true> then it works fine, exists is true or false.

But I don't want that user see the template column, I have it only for checking the exists value.


Where is the problem?

Thank you,

Simon
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,222
Members
46,810
Latest member
Kassie0918

Latest Threads

Top