Hello,
I have created a checkbox and textbox template fields in gridview and i have xml data source. as i click the button then the checked corresponding checkboxes the current date and time will appear into the respective textboxes
here is the HTML code which i have tried
<%
@ Page Language="C#" AutoEventWireup="true" CodeFile="BarcodeGen.aspx.cs" Inherits="BarcodeGen" %>DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
html xmlns="http://www.w3.org/1999/xhtml" ><
head runat="server"> <title>Untitled Pagetitle> <link href="gridview.css" rel="stylesheet" type="text/css" /> <script language=javascript>function
SelectAllCheckboxes(spanChk){// Added as ASPX uses SPAN for checkbox
var
oItem = spanChk.children;var
theBox=(spanChk.type=="checkbox")?spanChk:spanChk.children.item[0];xState=theBox.checked;
elm=theBox.form.elements;
for
(i=0;iif
(elm[i].type=="checkbox" && elm[i].id!=theBox.id){
//elm[i].click();
if
(elm[i].checked!=xState)elm[i].click();
//elm[i].checked=xState;
}
}
script><%
----%> head><
body> <form id="form1" runat="server"> <div> <table cellspacing="5" style="width: 190px; border-right: black 1px solid; border-top: black 1px solid; border-left: black 1px solid; border-bottom: black 1px solid;"> <tr> <td style="width: 97px"> td> tr> <tr> <td style="width: 97px"> <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" CssClass="grid-view" DataSourceID="XmlDataSource1" Width="190px" CellPadding="4" ForeColor="#333333" GridLines="None" AllowPaging="True" PageSize="5" OnRowDataBound="GridView1_RowDataBound" OnSelectedIndexChanged="GridView1_SelectedIndexChanged1" OnRowCommand="GridView1_RowCommand" OnSelectedIndexChanging="GridView1_SelectedIndexChanging"> <Columns> <asp:TemplateField HeaderText="Select"> <ItemTemplate> <asp:CheckBox ID="chkbox1" runat="server" /> ItemTemplate> <HeaderStyle HorizontalAlign="Left" VerticalAlign="Top" Width="20px" BorderColor="Black" BorderWidth="1px" /> <ItemStyle HorizontalAlign="Left" VerticalAlign="Top" Width="20px" BorderColor="Black" BorderWidth="1px" /> <HeaderTemplate> <asp:CheckBox ID="chkBxHeader" onclick="javascript:SelectAllCheckboxes(this);" runat="server" /> HeaderTemplate> <FooterStyle BorderColor="Black" BorderWidth="1px" /> asp:TemplateField> <asp:BoundField DataField="MRN" HeaderText="MRN" SortExpression="MRN" > <ItemStyle BorderColor="Black" BorderWidth="1px" Height="40px" /> <HeaderStyle BorderColor="Black" BorderWidth="1px" /> <FooterStyle BorderColor="Black" BorderWidth="1px" /> asp:BoundField> <asp:TemplateField HeaderText="SID"> <ItemTemplate> <asp:TextBox ID="TextBox1" runat="server" Width="100px" /> ItemTemplate> <ItemStyle BorderColor="Black" BorderWidth="1px" /> <HeaderStyle BorderColor="Black" BorderWidth="1px" /> <FooterStyle BorderColor="Black" BorderWidth="1px" /> asp:TemplateField> <asp:TemplateField HeaderText="SID"> <ItemTemplate> <asp:Image ID="Imgae1" runat="server" Height="50px" Width="200px" /> ItemTemplate> <ItemStyle BorderColor="Black" BorderWidth="1px" /> <HeaderStyle BorderColor="Black" BorderWidth="1px" /> <FooterStyle BorderColor="Black" BorderWidth="1px" /> asp:TemplateField> Columns> <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" /> <RowStyle BackColor="#EFF3FB" CssClass="normal" /> <EditRowStyle BackColor="#2461BF" /> <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" /> <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" /> <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" /> <AlternatingRowStyle BackColor="White" CssClass="alternate" /> asp:GridView><%
--AutoGenerateColumns="False" OnRowCreated="gvCheckboxes_RowCreated" Width="179px" DataSourceID="XmlDataSource1" CellPadding="4" CssClass="grid-view" ForeColor="#333333" GridLines="None">
onclick="javascript:HeaderClick(this);" runat="server" />
Butto
Replies
Know the answer? Post it — somebody with the same question will find it here.