DataGrid n CheckBoxList

Hi,
I built a dataGrid (auto generate) and add a column - TemplateColumn, and in it a CheckBoxList.
1) How can i make the Header of that column be like a linkLable/LinkButton (i did Allow Sorting=True, but nothing)
2) I need to click that LinkLable/LinkButton and turn all the CheckBoxes turn to "selected" and if click again, turn off.
Thanks
LVL 1
udirAsked:
Who is Participating?
 
Gautham JanardhanConnect With a Mentor Commented:
<asp:DataGrid id="DataGrid1" style="Z-INDEX: 101; LEFT: 170px; POSITION: absolute; TOP: 87px"
                        runat="server" AutoGenerateColumns="False" Width="309px">
                        <Columns>
                              <asp:TemplateColumn>
                                    <HeaderTemplate>
                                          <INPUT type="button" onclick = "CheckAll()" value="Button">
                                    </HeaderTemplate>
                                    <ItemTemplate>
                                          <asp:CheckBox id="CheckBox1" runat="server"></asp:CheckBox>
                                    </ItemTemplate>
                              </asp:TemplateColumn>
                              <asp:BoundColumn DataField="NAME"></asp:BoundColumn>
                        </Columns>
                  </asp:DataGrid>


function CheckAll()
      {
            alert("hi");
            return false;
      }

try this when u click the button u will get the message
0
 
renjurdevanCommented:
Set HeaderText property of templatcolumn accordingly

Regards
Renju
0
 
udirAuthor Commented:
Hi,
pls, can u give an example... i wrote :
<Columns>
                <asp:TemplateColumn HeaderText="Ñ×è">
                <ItemTemplate>
                <asp:CheckBoxList runat="server"
                   RepeatDirection="Horizontal" ID="Selection">
                    <asp:ListItem Selected="False"></asp:ListItem>
                    </asp:CheckBoxList>
                </ItemTemplate>
                </asp:TemplateColumn>
            </Columns>

where and what i need to add?
(and what about que 2?)
Thanks

0
 
Gautham JanardhanCommented:
and

      function CheckAll()
      {
            var data = document.getElementById("DataGrid1").all;
            for(var i=0;i<data.length;i++)
            {
                  if(data[i].id.indexOf("CheckBox1")>=0)
                  {
                        data[i].checked = true;
                  }
            }
            return false;
      }

to do check All
0
 
udirAuthor Commented:
Hi gauthampj,
Is there some option to add a LinkLable/LinkButton and not a button?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.