ASPX
<asp:Button id="Button1" runat="server" CommandName="MyCommand" Text="KlikMe" CommandArgument='<%# Container.DataItemIndex %>' />
<asp:Button id="Button1" runat="server" CommandName="MyCommand" Text="KlikMe" CommandArgument='<%# Container.DataItemIndex %>' />
Location <asp:CheckBoxList ID="CheckBoxList1" runat="server" AutoPostBack="True" DataSourceID="SqlDataSource1" DataTextField="Location" DataValueField="Location" RepeatDirection="Horizontal" RepeatLayout="Flow"> </asp:CheckBoxList> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:TESTConnectionString %>" SelectCommand="SELECT DISTINCT [Location] FROM [JOBTABLE] WHERE ([Location] IS NOT NULL) ORDER BY [Location]"> </asp:SqlDataSource> <asp:HiddenField ID="HiddenField1" runat="server" /> <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="JobId" DataSourceID="SqlDataSource2"> <Columns> <asp:BoundField DataField="JobId" HeaderText="JobId" InsertVisible="False" ReadOnly="True" SortExpression="JobId" /> <asp:BoundField DataField="Position" HeaderText="Position" SortExpression="Position" /> <asp:BoundField DataField="Company" HeaderText="Company" SortExpression="Company" /> <asp:BoundField DataField="Location" HeaderText="Location" SortExpression="Location" /> <asp:BoundField DataField="Experience" HeaderText="Experience" SortExpression="Experience" /> <asp:BoundField DataField="Information" HeaderText="Information" SortExpression="Information" /> </Columns> </asp:GridView> <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:TESTConnectionString %>" SelectCommand="SELECT * FROM [JOBTABLE] WHERE (@Location LIKE '%' + [Location] + '%')"> <SelectParameters> <asp:ControlParameter ControlID="HiddenField1" Name="Location" PropertyName="Value" Type="String" /> </SelectParameters> </asp:SqlDataSource>
protected void Page_Load(object sender, EventArgs e) { HiddenField1.Value = ""; foreach (ListItem li in CheckBoxList1.Items) { if (li.Selected == true) { HiddenField1.Value = HiddenField1.Value + "," + li.Text; } } }
Regex reg = new Regex("[;\\/:*?\"<>|&']"); documentName = reg.Replace(documentName, "-");
using System.Globalization; using System.Threading; private void Page_Load(object sender, System.EventArgs e) { Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(Request.UserLanguages[0].ToString()); Thread.CurrentThread.CurrentUICulture = new CultureInfo(Request.UserLanguages[0].ToString()); lblToday.Text = Today; lblMessage.Text = "Culture Info Display Name " + Thread.CurrentThread.CurrentCulture.DisplayName; }
<form id="form1" runat="server"> <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" BackColor="White" BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px" CellPadding="4" DataSourceID="SqlDataSource1" ForeColor="Black" GridLines="Horizontal" ShowHeader="False" Width="100%"> <Columns> <asp:TemplateField HeaderText="Genre" SortExpression="Genre"> <ItemTemplate> Genre : <asp:Label ID="Label1" runat="server" style="color: #FF0000; font-weight: 700;" Text='<%# Bind("Genre") %>'></asp:Label> <br /> <table class="style1"> <tr> <td class="style2"> </td> <td> <asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1" GridLines="None" ShowHeader="False" Width="100%"> <Columns> <asp:TemplateField HeaderText="Album" SortExpression="Album"> <ItemTemplate> Album : <asp:Label ID="Label1" runat="server" style="color: #0000FF; font-weight: 700" Text='<%# Bind("Album") %>'></asp:Label> <asp:HiddenField ID="HiddenField1" runat="server" Value='<%# Bind("Genre") %>' /> <table class="style1"> <tr> <td class="style2"> </td> <td> <asp:GridView ID="GridView3" runat="server" AutoGenerateColumns="False" BackColor="White" BorderColor="#DEDFDE" BorderStyle="None" BorderWidth="1px" CellPadding="4" DataSourceID="SqlDataSource1" ForeColor="Black" GridLines="Vertical" ShowHeader="False" Width="100%"> <RowStyle BackColor="#F7F7DE" /> <Columns> <asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title" /> </Columns> <FooterStyle BackColor="#CCCC99" /> <PagerStyle BackColor="#F7F7DE" ForeColor="Black" HorizontalAlign="Right" /> <SelectedRowStyle BackColor="#CE5D5A" Font-Bold="True" ForeColor="White" /> <HeaderStyle BackColor="#6B696B" Font-Bold="True" ForeColor="White" /> <AlternatingRowStyle BackColor="White" /> </asp:GridView> </td> </tr> </table> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:TESTConnectionString %>" SelectCommand="SELECT [Title] FROM [Music] WHERE (([Album] = @Album) AND ([Genre] = @Genre)) ORDER BY [Title]"> <SelectParameters> <asp:ControlParameter ControlID="Label1" Name="Album" PropertyName="Text" Type="String" /> <asp:ControlParameter ControlID="HiddenField1" Name="Genre" PropertyName="Value" Type="String" /> </SelectParameters> </asp:SqlDataSource> </ItemTemplate> <EditItemTemplate> <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Album") %>'></asp:TextBox> </EditItemTemplate> </asp:TemplateField> </Columns> </asp:GridView> </td> </tr> </table> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:TESTConnectionString %>" SelectCommand="SELECT DISTINCT [Album], [Genre] FROM [Music] WHERE (([Genre] = @Genre) AND ([Album] IS NOT NULL))"> <SelectParameters> <asp:ControlParameter ControlID="Label1" Name="Genre" PropertyName="Text" Type="String" /> </SelectParameters> </asp:SqlDataSource> </ItemTemplate> <EditItemTemplate> <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Genre") %>'></asp:TextBox> </EditItemTemplate> </asp:TemplateField> </Columns> <FooterStyle BackColor="#CCCC99" ForeColor="Black" /> <PagerStyle BackColor="White" ForeColor="Black" HorizontalAlign="Right" /> <SelectedRowStyle BackColor="#CC3333" Font-Bold="True" ForeColor="White" /> <HeaderStyle BackColor="#333333" Font-Bold="True" ForeColor="White" /> </asp:GridView> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:TESTConnectionString %>" SelectCommand="SELECT DISTINCT [Genre] FROM [Music] WHERE ([Genre] IS NOT NULL)"> </asp:SqlDataSource> </form>
<form id="form1" runat="server"> <div> <table> <tr> <td class="style1"> Genre</td> <td> <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" DataSourceID="SqlDataSource1" DataTextField="Genre" DataValueField="Genre" ondatabound="DropDownList1_DataBound"> <asp:ListItem Value="%">All Genre</asp:ListItem> </asp:DropDownList> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:TESTConnectionString %>" SelectCommand="SELECT DISTINCT [Genre] FROM [Music] WHERE ([Genre] IS NOT NULL)"> </asp:SqlDataSource> </td> </tr> <tr> <td class="style1"> Album</td> <td> <asp:DropDownList ID="DropDownList2" runat="server" AutoPostBack="True" DataSourceID="SqlDataSource2" DataTextField="Album" DataValueField="Album" ondatabound="DropDownList2_DataBound"> <asp:ListItem Value="%">All Album</asp:ListItem> </asp:DropDownList> <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:TESTConnectionString %>" SelectCommand="SELECT DISTINCT [Album] FROM [Music] WHERE (([Album] IS NOT NULL) AND ([Genre] LIKE @Genre))"> <SelectParameters> <asp:ControlParameter ControlID="DropDownList1" Name="Genre" PropertyName="SelectedValue" Type="String" /> </SelectParameters> </asp:SqlDataSource> </td> </tr> <tr> <td class="style1"> Title</td> <td> <asp:TextBox ID="TextBox1" runat="server" AutoPostBack="True"></asp:TextBox> </td> </tr> </table> <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" CellPadding="4" DataSourceID="SqlDataSource3" ForeColor="#333333" GridLines="None" Width="100%"> <RowStyle BackColor="#F7F6F3" ForeColor="#333333" /> <Columns> <asp:BoundField DataField="Genre" HeaderText="Genre" SortExpression="Genre" /> <asp:BoundField DataField="Album" HeaderText="Album" SortExpression="Album" /> <asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title" /> </Columns> <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" /> <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" /> <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" /> <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" /> <EditRowStyle BackColor="#999999" /> <AlternatingRowStyle BackColor="White" ForeColor="#284775" /> </asp:GridView> <asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:TESTConnectionString %>" SelectCommand="SELECT Genre, Album, Title FROM Music WHERE (Album LIKE '%' + @Album + '%') AND (Genre LIKE '%' + @Genre + '%') AND (Title LIKE '%' + @Title + '%')"> <SelectParameters> <asp:ControlParameter ControlID="DropDownList1" Name="Genre" PropertyName="SelectedValue" Type="String" /> <asp:ControlParameter ControlID="DropDownList2" Name="Album" PropertyName="SelectedValue" Type="String" /> <asp:ControlParameter ControlID="TextBox1" DefaultValue="%" Name="Title" PropertyName="Text" Type="String" /> </SelectParameters> </asp:SqlDataSource> </div> </form>
protected void DropDownList1_DataBound(object sender, EventArgs e) { DropDownList1.Items.Insert(0, new ListItem("All Genre", "%")); } protected void DropDownList2_DataBound(object sender, EventArgs e) { DropDownList2.Items.Insert(0, new ListItem("All Album", "%")); }