Click here to Skip to main content
15,922,584 members
Home / Discussions / C#
   

C#

 
QuestionRe: Create a grid of radiobutton on the fly Pin
Desmond Lim26-Mar-08 16:46
Desmond Lim26-Mar-08 16:46 
GeneralRe: Create a grid of radiobutton on the fly Pin
Gareth H27-Mar-08 0:06
Gareth H27-Mar-08 0:06 
QuestionRe: Create a grid of radiobutton on the fly Pin
Desmond Lim27-Mar-08 15:54
Desmond Lim27-Mar-08 15:54 
GeneralRe: Create a grid of radiobutton on the fly Pin
Gareth H28-Mar-08 2:31
Gareth H28-Mar-08 2:31 
GeneralDownload Pin
ellllllllie24-Mar-08 23:48
ellllllllie24-Mar-08 23:48 
GeneralRe: Download Pin
Christian Graus25-Mar-08 0:08
protectorChristian Graus25-Mar-08 0:08 
GeneralRe: Download Pin
ellllllllie25-Mar-08 0:49
ellllllllie25-Mar-08 0:49 
GeneralRe: Download Pin
Christian Graus25-Mar-08 1:06
protectorChristian Graus25-Mar-08 1:06 
GeneralRe: Download Pin
ellllllllie25-Mar-08 2:06
ellllllllie25-Mar-08 2:06 
GeneralRe: Download Pin
Christian Graus25-Mar-08 10:09
protectorChristian Graus25-Mar-08 10:09 
GeneralRe: Download Pin
Pete O'Hanlon25-Mar-08 2:51
mvePete O'Hanlon25-Mar-08 2:51 
GeneralRe: Download Pin
Eduard Keilholz25-Mar-08 2:54
Eduard Keilholz25-Mar-08 2:54 
GeneralRe: Download Pin
Pete O'Hanlon25-Mar-08 3:09
mvePete O'Hanlon25-Mar-08 3:09 
GeneralRe: Download Pin
Eduard Keilholz25-Mar-08 3:20
Eduard Keilholz25-Mar-08 3:20 
GeneralRe: Download Pin
Pete O'Hanlon25-Mar-08 3:28
mvePete O'Hanlon25-Mar-08 3:28 
GeneralRe: Download Pin
ellllllllie25-Mar-08 5:08
ellllllllie25-Mar-08 5:08 
GeneralRe: Download Pin
Pete O'Hanlon25-Mar-08 5:17
mvePete O'Hanlon25-Mar-08 5:17 
GeneralRe: Download Pin
ellllllllie25-Mar-08 5:37
ellllllllie25-Mar-08 5:37 
QuestionWhat is this problem? Pin
wsamuel24-Mar-08 22:51
wsamuel24-Mar-08 22:51 
AnswerRe: What is this problem?Urgent!!Please Help!! Pin
Gareth H25-Mar-08 0:01
Gareth H25-Mar-08 0:01 
GeneralRe: What is this problem?Urgent!!Please Help!! Pin
wsamuel25-Mar-08 1:55
wsamuel25-Mar-08 1:55 
GeneralRedirect standard input and output from C# to batch file Pin
Member 212296324-Mar-08 22:46
Member 212296324-Mar-08 22:46 
GeneralRe: Redirect standard input and output from C# to batch file Pin
Gareth H25-Mar-08 0:10
Gareth H25-Mar-08 0:10 
GeneralRe: Redirect standard input and output from C# to batch file Pin
m@u25-Mar-08 0:15
m@u25-Mar-08 0:15 
Generalcheck box inside the gridview Pin
chithra.r24-Mar-08 21:27
chithra.r24-Mar-08 21:27 
hi all
i have resolved the problem.here is the code

aspx page

&lt;html xmlns="http://www.w3.org/1999/xhtml" &gt;<br />
&lt;head runat="server"&gt;<br />
    &lt;title&gt;Untitled Page&lt;/title&gt;<br />
    &lt;script type="text/javascript"&gt;<br />
<br />
    function SelectAll(id) {<br />
    var frm = document.forms[0];<br />
    for (i=0;i&lt;frm.elements.length;i++) {<br />
    if (frm.elements[i].type == "checkbox") {<br />
     frm.elements[i].checked = document.getElementById(id).checked;<br />
             }<br />
        }<br />
    }  <br />
&lt;/script&gt;<br />
&lt;/head&gt;<br />
&lt;body&gt;<br />
    &lt;form id="form1" runat="server"&gt;<br />
    &lt;div&gt;<br />
&lt;asp:GridView ID="GridView1" runat="server" Width="400px" AutoGenerateColumns="False" OnRowDataBound="GridView1_RowDataBound"&gt;<br />
    &lt;Columns&gt;<br />
        &lt;asp:BoundField DataField="PersonID" HeaderText="PersonID" InsertVisible="False"<br />
                ReadOnly="True" /&gt;<br />
        &lt;asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" /&gt;<br />
        &lt;asp:TemplateField&gt;<br />
            &lt;%--&lt;AlternatingItemTemplate&gt;<br />
                &lt;asp:CheckBox ID="CheckBox1" runat="server" /&gt;<br />
            &lt;/AlternatingItemTemplate&gt;--%&gt;<br />
            &lt;ItemTemplate&gt;<br />
                &lt;asp:CheckBox ID="CheckBox1" runat="server" /&gt;<br />
            &lt;/ItemTemplate&gt;<br />
            &lt;HeaderTemplate&gt;<br />
                &lt;asp:CheckBox ID="cbSelectAll" runat="server" Text="Select All" /&gt;<br />
            &lt;/HeaderTemplate&gt;<br />
            &lt;HeaderStyle HorizontalAlign="Left" /&gt;<br />
            &lt;ItemStyle HorizontalAlign="Left" /&gt;<br />
        &lt;/asp:TemplateField&gt;<br />
    &lt;/Columns&gt;<br />
&lt;/asp:GridView&gt;<br />
    &lt;/div&gt;<br />
    &lt;/form&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;


code behind


protected void Page_Load(object sender, EventArgs e)
{
BindGrid();
}
private void BindGrid()
{
string Connstr = "connection string";
SqlConnection Conn = new SqlConnection(Connstr);
string str = "select * from emp";
SqlCommand cmd = new SqlCommand(str, Conn);
Conn.Open();
DataSet ds = new DataSet();
SqlDataAdapter Adap = new SqlDataAdapter();
Adap.SelectCommand = cmd;
Adap.Fill(ds);
GridView1.DataSource = ds;
GridView1.DataBind();
}

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.Header)
{
//adding an attribute for onclick event on the check box in the header
//and passing the ClientID of the Select All checkbox
((CheckBox)e.Row.FindControl("cbSelectAll")).Attributes.Add("onclick", "javascript:SelectAll('" + ((CheckBox)e.Row.FindControl("cbSelectAll")).ClientID + "')");
}
}

pintoo

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.