?
Solved

DataGrid n CheckBoxList

Posted on 2007-08-08
5
Medium Priority
?
209 Views
Last Modified: 2010-04-15
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
0
Comment
Question by:udir
  • 2
  • 2
5 Comments
 
LVL 12

Expert Comment

by:renjurdevan
ID: 19652039
Set HeaderText property of templatcolumn accordingly

Regards
Renju
0
 
LVL 1

Author Comment

by:udir
ID: 19652062
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
 
LVL 29

Accepted Solution

by:
Gautham Janardhan earned 1500 total points
ID: 19652146
<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
 
LVL 29

Expert Comment

by:Gautham Janardhan
ID: 19652214
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
 
LVL 1

Author Comment

by:udir
ID: 19652263
Hi gauthampj,
Is there some option to add a LinkLable/LinkButton and not a button?
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Integration Management Part 2
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses

755 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question