TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Ramya S
NA
79
8.1k
bind data to gridview without database
Jul 8 2016 7:42 AM
My webform consists textbox,checkbox,radiobutton,on submit the data to bind to grindview and display.
here my aspx code is:
<body>
<form id="form1" runat="server">
<div>
<table border="0" align="center">
<tr><td>name:</td><td><asp:TextBox id="txt1" size="20" runat="server" ></asp:TextBox>
</td></tr>
<tr><td>mobile number:</td><td><asp:TextBox id="txt2" onkeypress="return Check_Nums(event)" maxlength="13" runat="server"></asp:TextBox></td></tr>
<tr><td>Email:</td><td><asp:TextBox id="mail" onblur="return emailvald()" runat="server"></asp:TextBox></td></tr>
<tr>
<td>
state:
</td><td>
<select name="state" id="state">
<option value="select" selected="selected" runat="server">select</option>
<option value="ap">AP</option>
<option value="tp">TP</option>
<option value="up">up</option>
<option value="mp">mp</option>
</select>
</td>
</tr>
<tr>
<td> select course:</td>
<td><input type="checkbox" id="chb1" onclick="return disc()" runat="server"/>html(300 rs)<br /></td>
</tr>
<tr><td> </td><td><input type="checkbox" id="chb2" onclick="return disc()" runat="server"/>javascript-css(1000 rs) </td></tr>
<tr><td> </td> <td><input type="checkbox" id="chb3" onclick="return disc()" runat="server"/>c(500 rs)</td></tr>
<tr><td> </td> <td><input type="checkbox" id="chb4" onclick="return disc()" runat="server"/>.net(2500 rs)</td></tr>
<tr><td> </td><td><input type="checkbox" id="chb5" onclick="return disc()" runat="server"/>java(3000 rs)</td></tr>
<tr><td>Applictiona fee:</td><td><input type="text" id="appid" readonly="readonly" value="50" runat="server"/>(* application fee (50 rs/-)</td></tr>
<tr><td>Total amount:</td><td><input type="text" id="totid" readonly="readonly" runat="server"/>(include application fee.)</td></tr>
<tr><td>Timmings:</td><td><input type="radio" id="rd1" name="time" runat="server"/>7:00-9:00am(fasttrack)</td></tr>
<tr>
<td> </td>
<td>
<input type="radio" id="rd2" name="time" runat="server"/>11:00-12:00pm(normaltrack)
</td>
</tr>
<tr>
<td> </td>
<td>
<input type="radio" id="rd3" name="time" runat="server"/>5:00-7:00pm
</td>
</tr>
<tr><td></td><td>
<asp:Button ID="sub" runat="server" Text="submitt" OnClientClick="return func()" OnClick="sub_Click" />
</td></tr>
</table>
<table border="0" align="center">
<asp:GridView ID="gvbind" AutoGenerateColumns="false" runat="server">
<Columns>
<asp:BoundField HeaderText="Name" DataField="name"/>
<asp:BoundField HeaderText="Email" DataField="email" />
<asp:BoundField HeaderText="Selectcourse" DataField="selectcourse" />
<asp:BoundField HeaderText="Total Amount" DataField="totalamount" />
</Columns>
</asp:GridView>
</table>
</div>
</form>
</body>
and my cs code:
public partial class jsv : System.Web.UI.Page
{
DataTable dt = new DataTable();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
DataTable dt = new DataTable();
dt.Columns.Add(new DataColumn("name"));
dt.Columns.Add(new DataColumn("email"));
dt.Columns.Add(new DataColumn("selectcourse"));
dt.Columns.Add(new DataColumn("totalamount"));
DataRow dr = dt.NewRow();
gvbind.DataSource = dt;
gvbind.DataBind();
}
}
protected void sub_Click(object sender, EventArgs e)
{
DataRow dr = dt.NewRow();
dr[1] = txt1.Text;----------------imgetting error here
dr[2] = txt2.Text;
gvbind.DataSource = dt;
gvbind.DataBind();
}
And i need how to bind multiple checked value and radio button value in gridview
Reply
Answers (
2
)
how to set previous data in gridview while adding new row
Adapative web page implementation