.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

Populate RadiobuttonList from Database

Posted By:      Posted Date: September 22, 2010    Points: 0   Category :ASP.Net


I am using:

 If IsDBNull(ds.Tables("tblStateDocuments").Rows(0).Item("IsPublic")) Then


 DropDownList3.SelectedValue = varDocPublic

 Dim varDocPublic As String = (ds.Tables("tblStateDocuments").Rows(0).Item("IsPublic"))

View Complete Post

More Related Resource Links

Populate asp:RadioButtonList with values from database


Hi All!

I have a gridview with a RadioButtonList I need to populate. It is as such"

<asp:GridView ID="GridView1" AllowPaging="true" PageSize="7" runat="server" DataSourceID="mainDS"

DataKeyNames="id" AutoGenerateColumns="False" Width="100%" RowStyle-BackColor="LightGray"

AutoGenerateEditButton="false" AutoGenerateSelectButton="false" AlternatingRowStyle-BackColor="white"

HeaderStyle-BackColor="Black" HeaderStyle-ForeColor="white" ForeColor="black"

PagerStyle-ForeColor="#1A7A5E" EmptyDataText="No Data To Display">


<asp:BoundField HeaderText="Question" DataField="number" ItemStyle-Wrap="false" ItemStyle-VerticalAlign="Top" />

<asp:BoundField DataField="question" ItemStyle-Wrap="false" ItemStyle-VerticalAlign="Top" />

<asp:TemplateField HeaderText="Select">


<asp:Label ID="Qid" Text='<%# Eval("number") %>' runat="server" Visible="false" />

<asp:RadioButtonList ID="answer" runat="server"

Is it possible to populate property choices from a database?


I'm creating my first server control, and have it working where I can set up an enum and the user can set a property's choices,  based off of that enum.  But I'd like it to pull records from a database and populate the list of choices for the property from a database.  This would allow me to add a new "Host System" to the database, and the other designers wouldn't have to get a new copy of the dll.



Write select query with a paremetrized where clause, and populate database with the retrieved column

I want to be able to retrieve column values using the dropdownlist values as parameters then populate the tbPO table with the retreived values. Where and how do I do it. ImportsSystem.Data.OleDb ImportsSystem ImportsSystem.IO Imports ?directcostDataSetTableAdapters PartialClass po_header  Inherits System.Web.UI.Page  Dim cn As OleDbConnection  Dim cmd As OleDbCommand  Dim dr As OleDbDataReader  Dim icount As Integer  Dim str As String  Dim vendor_id As Object   ?  Public Sub btn_click(ByVal sender As Object, ByVal e As System.EventArgs) Handles button1.ClickTry   context.Items.Add(     cmd.CommandType = System.Data.   cmd.CommandText = Dim context As HttpContext = HttpContext.Current"Company_Name", DropDownList3.Text)Dim cn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\Users\Owner\Documents\Visual Studio 2010\WebSites\WebSiteJun25\App_Data\directcost.mdb;")Dim cmd As New OleDbCommand()CommandType.Text"insert into tbPO(ponumber, suppliername, ShipTo, basictype, DateNeeded, Purpose,ShippingInstr, ProjId) values(?,?,?,?,?,?,?,?)" cmd.Parameters.AddWithValue( cmd.Parameters.AddWithValue( cmd.Parameters.AddWithValue( cmd.Parameters.AddWithValue( cmd.Parameters.AddWithValue( cmd.Parameters.AddWithValue( cmd.Parameters.AddWithValue( cmd.Parameters.Add

how to save radiobuttonlist data into database when they are in disable position

hiiiiiam using 2 radio buttonlist controls in web application they are FIRST      Yes    NoSECOND  Yes    NoInitially  SECOND radio button list is in disable position.when i was click on yes of FIRST radio button list, then SECOND radio button list is enables otherwise it is in disable mode only.here my problem is when i am inserting data into the database the disable radio button list gives error as System.NullReferenceException: Object reference not set to an instance of an object.code written for inserting isprotected void Button1_Click(object sender, EventArgs e)    {                    SqlConnection con = new SqlConnection(@"Data Source=STS2\SQLEXPRESS;Initial Catalog=STS;Integrated Security=True");            string sql;            sql = "insert into Table1(";            sql += "First,Second)";            sql += "values('";            sql += rbl_first.SelectedItem.Value.ToString() + "&

dropdown list wont populate values from database


Hello everyone i need help. Ive been having this problem for almost  3 days now. dropdown list won't populate from database

Below is the code i am using:

<%@ Page Title="" Language="VB" MasterPageFile="~/Site.master" AutoEventWireup="false" CodeFile="PhotoAlbum.aspx.vb" Inherits="PhotoAlbum" %>

<asp:SqlDataSource ID="categoriesDataSource" runat="server"  
<%$ ConnectionStrings:ConnectionString %>"  
    SelectCommand="SELECT [CategoryID], [Name] FROM [Categories] WHERE ([UserId] = @UserId) ORDER BY [Name]"> 
<asp:QueryStringParameter Name="UserId" QueryStringField="ID"/> 

load new page and populate the values without database



I'm creating a website of 5 pages using c# (asp.net).

How do i link 2 pages, ie., on click of a button on first page should take me to second page.

Advance thanks,


How to manually populate a listview control without a database connection?


Hi to all,

I'm currently developing an ASP.net application w/ VB as the code behind. I have a page that shows all the user name currently assigned to the system. The problem now is that the page does not communicate directly to the database. Instead, I use HTTPrequest to get all the user names from a different sever. Now I want to populate the listview control w/ the response that I got (and not directly from the database).

How should I do it? Please help.



Populate entity data model from database


I've been using entity data models for quite a few sections of my website and find it really good for saving things to the database.

After searching for a while, I can't seem to find a good way to populate a new instance with data from a database other than using a data reader. E.G:

MyClass.myID = reader("myID")

Am I missing something?

How to populate RadioButtonList using 3-tier Logic


The below code doesn't work becuase I need to somehow feed the DataText and Value fields. I need to somehow amend the code to allow me to populate my RadioButtonList and to fit inside my 3-tier architecture.  My first time doing this so I'm a little lost.

rblAnswers.DataSource = rblDataSource(QuestionID)
' rblAnswers.DataTextField = dt.Columns(1).ToString
' rblAnswers.DataValueField = dt.Columns(0).ToString


 Private Function rblDataSource(ByVal QuestionID As Integer) As DataTable

        Dim SurveyID As Integer = Convert.ToInt32(Request.QueryString("id"))

        Dim p As New SurveyDAL()
        Dim dTable As New DataTable()
            dTable = p.GetAnswers(SurveyID, QuestionID)
        Catch ee As Exception
            lblMessage.Text = ee.Message.ToString()
            p = Nothing
        End Try

        Return dTable
    End Function

'Which Calls

Public Function GetAnswers(ByVal ID As Integer, ByVal Question As Integer) As DataTable

        Dim conn As New SqlConnection(connStr)
        Dim dAd As New SqlDataAdapter("GetAnswers", conn)
        dAd.SelectCommand.CommandType = CommandType.StoredProcedure

populate pdf form fields from database or XML


 Hi, I have a web app that stores data in an SQL database. What I want to be able to do is to have a pdf form with fields that I can later populate with the database info. I can either go directly from the database or I can perform an intermediate conversion to XML if that will work better. Can anyone point me towards a tutorial or a step by step explanation of how to get started? I'm pretty much a noob in the pdf world.


Mark B

Multiple database support with Entity Framework

One of the features introduced in Entity Framework is being database independent. Which mean each database provider can support Entity Framework by implementing its provider.

This feature allows you build applications independent from the underplaying database provider. In this post I'm going to show how to build an application that support multiple databases using same conceptual model made by Entity Framework.

Export Visio Database Table Names to Excel

If you use the Enterprise Architect edition of Microsoft Visio for data modeling regularly, then there is a good chance that at some point you've wanted to export just the table names into Excel. You might want to do this to map logical ERD entities to physical data model tables, track project status by entity, or track overlap between database versions.

MS SQL Server: Disconnect Users From Database - Kill User Session

If you ever wanted to restore your database from a SQL backup file (.bak), but there are still users connected to your database, the backup operation will fail causing the error: Exclusive access could not be obtained because the database is in use.

Publishing SQL Server Database using Publishing Wizard : Tips & Tricks

We can use SQL Server Publishing Wizard to deploy our local Database to remote hosting server/production server.This feature is available in SQL Server 2008/VWD 2008.

Below is the complete step by step guide of this process.

Adding Rows in GridView without using a Database

This article describes on how to add rows in GridView without using a database. Basically the GridView will be populated with data based on the values entered in the TextBox on Button Click and retain the GridView data on post back.

Adding Multiple Columns and Rows in GridView without using a Database

This article describes on how to add multiple columns and rows in GridView without using a database. Basically the GridView will be populated with data based on the values entered in each TextBoxes on Button Click and retain the GridView data on post back.

ASP.NET Database Tutorial

This tutorial will show you how to display data using the .NET GridView Control, ASP.NET 2.0 and VB.NET

The GridView control is a powerful tool and is simple to implement.

First, you will need to import the System.Data.SqlClient namespace.
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend