How to use a RangeValidator to select Colors from a specific range
<asp:dropdownlist id=’DropDownList1′ runat=’server’> <asp:ListItem Value =’#000000′>#000000</asp:ListItem> <asp:ListItem Value =’#ff0000′>#ff0000</asp:ListItem> <asp:ListItem Value =’#0000ff’>#0000ff</asp:ListItem> <asp:ListItem Value =’#00aacc’>#00aacc</asp:ListItem> <asp:ListItem Value =’#0000cc’>#0000cc</asp:ListItem> <asp:ListItem Value =’#cc0000′>#cc0000</asp:ListItem> <asp:ListItem Value =’#00ff00′>#00ff00</asp:ListItem> </asp:dropdownlist> <asp:rangevalidator id=’RangeValidator1′ runat=’server’ ErrorMessage=’Select a color between #00ff00 to #ff0000′ ControlToValidate=’DropDownList1′ MaximumValue=’#ff0000′ MinimumValue=’#00ff00′> </asp:rangevalidator>
How to pass argument to accessdatasourcecontrol selectcommand statement
VB.NET AccessDataSourceControl1.SelectCommand = ‘SELECT * FROM <tablename> WHERE <fieldname> = ‘ & Request(‘CustID’) C# AccessDataSourceControl1.SelectCommand = ‘SELECT * FROM <tablename> WHERE <fieldname> = ‘+ Request[‘CustID’]
How to access the BoundColumn information on SelectedIndexChanged event of a datagrid
<asp:Label id=’Label1′ runat=’server’>Label</asp:Label> <asp:DataGrid id=’DataGrid1′ OnSelectedIndexChanged=SelectedIndexChg AutoGenerateColumns=’False’ runat=’server’> <Columns> <asp:ButtonColumn Text =’Select’ ButtonType =PushButton CommandName =’Select’ ></asp:ButtonColumn> <asp:BoundColumn Headertext=’ProductId’ DataField=’Productid’></asp:BoundColumn> <asp:BoundColumn Headertext=’ProductName’ DataField=’ProductName’></asp:BoundColumn> </Columns> </asp:DataGrid> VB.NET Protected Sub SelectedIndexChg(ByVal sender As Object, ByVal e As System.EventArgs) Label1.Text = DataGrid1.SelectedItem.Cells(1).Text & DataGrid1.SelectedItem.Cells(2).Text End Sub C# protected void SelectedIndexChg(object sender, System.EventArgs e) { Label1.Text = DataGrid1.SelectedItem.Cells[1].Text + DataGrid1.SelectedItem.Cells[2].Text ; }
How to use a HyperlinkColumn for a DataGrid
<asp:DataGrid id=’DataGrid1′ AutoGenerateColumns=’False’ runat=’server’> <Columns> <asp:HyperLinkColumn HeaderText=’ID’ DataNavigateUrlField=’ID’ DataNavigateUrlFormatString=’page2.aspx?id={0}’ DataTextField=’ID’></asp:HyperLinkColumn> </Columns> </asp:DataGrid>
How to select a specific Item in a DropDownList
Method 1: VB.NET DropDownList1.SelectedIndex = DropDownList1.Items.IndexOf(DropDownList1.Items.FindByValue(<value>)) ’DropDownList1.SelectedIndex = DropDownList1.Items.IndexOf(DropDownList1.Items.FindByText(<Text>)) C# DropDownList1.SelectedIndex = DropDownList1.Items.IndexOf(DropDownList1.Items.FindByValue(<value>)); //DropDownList1.SelectedIndex = DropDownList1.Items.IndexOf(DropDownList1.Items.FindByText(<Text>)); Method 2: VB.NET DropDownList1.Items.FindByText(‘<Text>’).Selected = true ’DropDownList1.Items.FindByValue(‘<value>’).Selected = true C# DropDownList1.Items.FindByText(‘<Text>’).Selected = true ; //DropDownList1.Items.FindByValue(‘<value>’).Selected = true ;