gridview control problem - asp.net

work on C# asp.net vs05. i take a combo on gridview template field.
<asp:GridView ID="GridView3" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource3">
<Columns>
<asp:BoundField DataField="StudentID" HeaderText="StudentID" ReadOnly="True" SortExpression="StudentID" />
<asp:TemplateField HeaderText="DivisionName" SortExpression="DivisionName">
<ItemTemplate>
<asp:Label ID="lblDivisionName" runat="server" Text='<%# Bind("DivisionName") %>'
Width="116px"></asp:Label><br />
<asp:DropDownList ID="DropDownList1" runat="server">
</asp:DropDownList>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="StudentName" SortExpression="StudentName">
<EditItemTemplate>
<asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("StudentName") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Bind("StudentName") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:ButtonField ButtonType="Button" Text="Update" />
</Columns>
</asp:GridView>
Now i want to fill this combo by the bellow code ?
DropDownList1.DisplayMember = "CommercialRegionName";
foreach (object oItem in collection)
{
DropDownList1.Items.Add(oItem);
}
how to get the combo control id from the grid

You can use the following code:
Set OnRowDataBound of the gridview in aspx as OnRowDataBound="GridView3_RowDataBound"
Then put the following code in aspx.cs page.
protected void GridView3_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
DropDownList DropDownList1 =(DropDownList) e.Row.FindControl("DropDownList1");
DropDownList1.DisplayMember = "CommercialRegionName";
foreach (object oItem in collection)
{
DropDownList1.Items.Add(oItem);
}
}
}

Related

How to show and hide textbox in gridview on link button click

I have gridview,which has approve and reject button.When click on reject button i need to show textbox for comments else no.after enetering comments i have save it in data base.How to do this can any one help me
here is my code:
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AutoGenerateColumns="False" BackColor="White"
BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px" CellPadding="4" ForeColor="Black"
GridLines="Horizontal" OnRowDataBound="GridView1_RowDataBound">
<Columns>
<asp:TemplateField HeaderText="Industrial Zone">
<ItemTemplate>
<asp:Label runat="server" ID="lblindzone" Text='<%# Eval("indzone") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="District">
<ItemTemplate>
<asp:Label runat="server" ID="lbldstr" Text='<%# Eval("dstr")%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Industrial Area">
<ItemTemplate>
<asp:Label runat="server" ID="lblnmindar" Text='<%# Eval("nmindar")%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Plot Number">
<ItemTemplate>
<asp:Label runat="server" ID="lblplno" Text='<%# Eval("plno")%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Approve/Reject">
<ItemTemplate>
<asp:LinkButton ID="lnkApproved" runat="server" Text="Approve" OnClick="lnkApproved_Click"><img src="images/approve.png" style="width:20px;height:20px; margin:5px" title="Approve"/></asp:LinkButton>
<asp:LinkButton ID="lnkReject" runat="server" Text="Reject" OnClick="lnkReject_Click" OnClientClick="return showandhide(this)"><img src="images/reject.png" style="width:16px;height:16px; margin:5px" title="Reject"/></asp:LinkButton>
<asp:LinkButton ID="lnkviewdetails" runat="server" Text="View Details" OnClick="lnkviewdetails_Click"><img src="images/viewdetails.png" style="width:20px;height:20px; margin:5px" title="Details" /></asp:LinkButton>
<asp:TextBox ID="txtcomment" runat="server" style="display:none"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Status">
<ItemTemplate>
<asp:Label runat="server" ID="lblstatus" Text='<%# Eval("status")%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
I am assuming you are doing it with only C# and no Javascript. to view or hide a specific textbox you should trigger a RowCommand Event of GridView:
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "viewhide")
{
GridViewRow gvr = (GridViewRow)(((LinkButton)e.CommandSource).NamingContainer);
TextBox tbComments = ((TextBox)gvr.FindControl("txtcomment"));
tbComments.Visible = true;
}
}
And this would be your ASPX Codebehind
<asp:LinkButton ID="lnkReject" runat="server" Text="Reject" OnClick="lnkReject_Click" CommandName="viewhide" OnClientClick="return showandhide(this)"><img src="images/reject.png" style="width:16px;height:16px; margin:5px" title="Reject"/></asp:LinkButton>
EDIT: Now You've changed the tag from C# to VB.NET which is not good. because i consumed all my time writing a c# code!

disable button in gridview

I have a Gridview:
<asp:GridView ID="gvtransaction" runat="server" AutoGenerateColumns="False" Width="60%" OnRowDataBound="gvtransaction_RowDataBound" >
<Columns>
<asp:TemplateField HeaderText="">
<ItemTemplate>
<asp:Label ID="lblid" runat="server" Text='<%# Bind("id") %>' Visible="false"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Consumer">
<ItemTemplate>
<asp:Label ID="lblfirstname" runat="server" Text='<%# Bind("FirstName") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Name">
<ItemTemplate>
<asp:Label ID="lbllastname" runat="server" Text='<%# Bind("LastName") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Amount">
<ItemTemplate>
<asp:Label ID="lblamount" runat="server" Text='<%# Bind("Amount") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="">
<ItemTemplate>
<asp:Label ID="lblcurrencyID" runat="server" Text='<%# Bind("CurrencyID") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Account Name">
<ItemTemplate>
<asp:Label ID="lblcurrencyname" runat="server" Text='<%# Bind("CurrencyName") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Status">
<ItemTemplate>
<asp:Label ID="lblstatus" runat="server" Text='<%# Bind("Status") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="DateCreated">
<ItemTemplate>
<asp:Label ID="lbldatecreated" runat="server" Text='<%# Bind("DateCreated") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="">
<ItemTemplate>
<asp:Button ID="btnApprove" runat="server" Text="Approve" OnClick="btnApprove_Click"/>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="">
<ItemTemplate>
<asp:Button ID="btnReject" runat="server" Text="Reject" OnClick="btnReject_Click" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
here is the code for the onclick = "btnApprove_click():
GridViewRow row = ((Button)sender).Parent.Parent as GridViewRow;
string id = ((Label)row.FindControl("lblid")).Text;
Response.Write(row.RowIndex);
string ApprovedStatus = "Approved";
Button btnApprove = (Button)sender;
btnApprove.Enabled = false;
string status = ClassBiller.ConsumerAcceptedStatus(int.Parse(id), ApprovedStatus, DateTime.Now);
ViewPendingConsumer(); //rebind gridview para magEffect yun update
my concern is, how can i disable the buttons inside my gridview when i clicked either the Approve Button or the Reject Button.
sample scenario:
when I click Approve, the buttons should be disabled so that the it will prevent the user to click the button again..
I have read some articles which suggests the use of gridview's onrowdatabound..But i am confuse on how to do it...
I tried using
row.Enabled = false;
still doesnt work...
help please..
thank you
You can try to disable the button inside its click event. But when your gridview databinds again, the button will be enabled back..
protected void btnApprove_Click(object sender, EventArgs e)
{
Button btnApprove = (Button)sender;
btnApprove.Enabled = false;
}
Try to use rowdatabound event of Grid View, Firstly Find the control by using FindControl method like
protected void gvtransaction_RowDataBound(object sender, GridViewRowEventArgs e)
{
if(e.Row.RowType == DataControlRowType.DataRow)
{
// For `Approve` button
Button btnapprove = (Button)e.Row.FindControl("btnApprove"); // give property id of button form template field
btnapprove.Enabled = true; //true means enable else you may set false to disable button
// For `Reject` button
// Same condition but in `FindControl` method use `btnReject` id.
}
}
That's for Approve button For Reject button you may use same logic.
Link For Help
Hope it clear and works for you.
This is all you need to do, where Cells[5] is the cell where you have your Button, had the same problem and it worked for me.
protected void gvtransaction_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Cells[5].Enabled = false;
}
}

GridViewCosts.SelectedRow.Cells[1].Text dont work with itemTemplate

I have this gridView:
<div class ="gridView">
<asp:GridView ID="GridViewCosts" runat="server" ShowFooter="True" ShowHeaderWhenEmpty="True"
AutoGenerateColumns="False" OnRowDeleting="GridViewCosts_RowDeleting" Width="387px"
OnSelectedIndexChanged="GridViewCosts_SelectedIndexChanged"
OnPageIndexChanging="GridViewCosts_PageIndexChanging"
AllowPaging="True"
CssClass="mGrid"
PagerStyle-CssClass="pgr"
AlternatingRowStyle-CssClass="alt" PageSize="5">
<AlternatingRowStyle CssClass="alt"></AlternatingRowStyle>
<Columns>
<asp:BoundField DataField="Id" HeaderText="Номер" />
<asp:TemplateField HeaderText="Стойност">
<EditItemTemplate>
<asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("Value") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Bind("Value") %>'></asp:Label>
</ItemTemplate>
<ControlStyle Width="100px" />
</asp:TemplateField>
And in code behind i Want :
protected void GridViewCosts_SelectedIndexChanged(object sender, EventArgs e)
{
TextBoxValue.Text = GridViewCosts.SelectedRow.Cells[1].Text;
}
this is not working when the column Value is TemplateField. If the column is BoundFIeld it's working . What should i do ?
If you use TemplateFields you have to use FindControl to get a reference to the control:
Label Label2 = (Label)GridViewCosts.SelectedRow.FindControl("Label2");
TextBoxValue.Text = Label2.Text;
Try this sample code
For Each gvr As GridViewRow In gvInvoice.Rows
Dim TctValue As TextBox= DirectCast(GridViewCosts.Cells(1).FindControl("TextBox2"), TextBox)
totamount = totamount + Convert.ToDouble(lblAmount.Text)
Next
txtTotal.Text = totamount.ToString()

Update textbox via onchange event of a dropdownlist while editing in gridview

I am trying to update a TextBox within currently edited row within a GridView on when changing items on a DropDownList and I cant quite get it going in VB. I found this code in c# but don't know if I'm on the right track?
Can you please offer some help?
PS: This code is for an OnMouseOver event but the point is to update the TextBox while in edit mode.
<ItemTemplate>
<asp:TextBox runat="server" ID="tx1" onmouseover='<%# "ChangeValue(" +((DataGridItem)Container).FindControl("tx1").ClientID + ")"%>'></asp:TextBox>
</ItemTemplate>
JS Code:
function ChangeValue(i)
{
var t=i.id
document.getElementById(t).value="Hello World!";
}
Try the following:
Put the following script in head tag:
<script language="javascript" type="text/javascript">
function ChangeValue(ddl,txtid)
{
var txt=document.getElementById(txtid);
var dval= ddl.options[ddl.selectedIndex].value;
if(dval=="1")
{
txt.value="It's 1";
}
if(dval=="2")
{
txt.value="It's 2";
}
if(dval=="3")
{
txt.value="It's 3";
}
}
</script>
Try the gridview below:
<asp:GridView ID="GridView1" OnRowEditing="GridView1_RowEditing" OnRowUpdating="GridView1_RowUpdating"
AutoGenerateColumns="false" OnRowCancelingEdit="GridView1_RowCancelingEdit" OnRowCommand="GridView1_RowCommand"
runat="server" OnRowCreated="GridView1_RowCreated">
<Columns>
<asp:CommandField ButtonType="link" ShowEditButton="true" ShowCancelButton="true" />
<asp:TemplateField HeaderText="CategoryID">
<ItemTemplate>
<asp:LinkButton ID="lnkID" runat="server" CommandName="sel" CommandArgument='<%# DataBinder.Eval(Container,"DataItem.CategoryID") %>'
Text='<%# DataBinder.Eval(Container,"DataItem.CategoryID") %>'></asp:LinkButton>
</ItemTemplate>
<EditItemTemplate>
<asp:DropDownList ID="ddl" runat="server">
<asp:ListItem Text="1" Value="1" Selected="true"></asp:ListItem>
<asp:ListItem Text="2" Value="2"></asp:ListItem>
<asp:ListItem Text="3" Value="3"></asp:ListItem>
</asp:DropDownList>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Comments">
<ItemTemplate>
<asp:Label ID="lblID" runat="server" Text='<%# DataBinder.Eval(Container,"DataItem.CategoryID") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtComments" runat="server"></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="CategoryName">
<ItemTemplate>
<asp:LinkButton ID="lnkName" runat="server" CommandName="sel" CommandArgument='<%# DataBinder.Eval(Container,"DataItem.CategoryName") %>'
Text='<%# DataBinder.Eval(Container,"DataItem.CategoryName") %>'></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
Handle the rowcreated event in codebehind:
protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowState == DataControlRowState.Edit)
{
DropDownList ddl = (DropDownList)e.Row.FindControl("ddl");
TextBox txt = (TextBox)e.Row.FindControl("txtComments");
txt.Text = "It's 1";
//------------ Set onchange function for dropdown---------------------------//
ddl.Attributes.Add("onchange", "javascript:ChangeValue(this,'" + txt.ClientID + "');");
}
}
Bind the grid with Categories table in northwind db.

Gridview row editing - dynamic binding to a DropDownList

I'm trying to get an ASP.NET 3.5 GridView to show a selected value as string when being displayed, and to show a DropDownList to allow me to pick a value from a given list of options when being edited. Seems simple enough?
My gridview looks like this (simplified):
<asp:GridView ID="grvSecondaryLocations" runat="server"
DataKeyNames="ID" OnInit="grvSecondaryLocations_Init"
OnRowCommand="grvSecondaryLocations_RowCommand"
OnRowCancelingEdit="grvSecondaryLocations_RowCancelingEdit"
OnRowDeleting="grvSecondaryLocations_RowDeleting"
OnRowEditing="grvSecondaryLocations_RowEditing"
OnRowUpdating="grvSecondaryLocations_RowUpdating" >
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:Label ID="lblPbxTypeCaption" runat="server"
Text='<%# Eval("PBXTypeCaptionValue") %>' />
</ItemTemplate>
<EditItemTemplate>
<asp:DropDownList ID="ddlPBXTypeNS" runat="server"
Width="200px"
DataTextField="CaptionValue"
DataValueField="OID" />
</EditItemTemplate>
</asp:TemplateField>
</asp:GridView>
The grid gets displayed OK when not in editing mode - the selected PBX type shows its value in the asp:Label control. No surprise there.
I load the list of values for the DropDownList into a local member called _pbxTypes in the OnLoad event of the form. I verified this - it works, the values are there.
Now my challenge is: when the grid goes into editing mode for a particular row, I need to bind the list of PBX's stored in _pbxTypes.
Simple enough, I thought - just grab the drop down list object in the RowEditing event and attach the list:
protected void grvSecondaryLocations_RowEditing(object sender, GridViewEditEventArgs e)
{
grvSecondaryLocations.EditIndex = e.NewEditIndex;
GridViewRow editingRow = grvSecondaryLocations.Rows[e.NewEditIndex];
DropDownList ddlPbx = (editingRow.FindControl("ddlPBXTypeNS") as DropDownList);
if (ddlPbx != null)
{
ddlPbx.DataSource = _pbxTypes;
ddlPbx.DataBind();
}
.... (more stuff)
}
Trouble is - I never get anything back from the FindControl call - seems like the ddlPBXTypeNS doesn't exist (or can't be found).
What am I missing?? Must be something really stupid.... but so far, all my Googling, reading up on GridView controls, and asking buddies hasn't helped.
Who can spot the missing link? ;-)
Quite easy... You're doing it wrong, because by that event the control is not there:
protected void gv_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow &&
(e.Row.RowState & DataControlRowState.Edit) == DataControlRowState.Edit)
{
// Here you will get the Control you need like:
DropDownList dl = (DropDownList)e.Row.FindControl("ddlPBXTypeNS");
}
}
That is, it will only be valid for a DataRow (the actually row with data), and if it's in Edit mode... because you only edit one row at a time. The e.Row.FindControl("ddlPBXTypeNS") will only find the control that you want.
I am using a ListView instead of a GridView in 3.5. When the user wants to edit I have set the selected item of the dropdown to the exising value of that column for the record. I am able to access the dropdown in the ItemDataBound event. Here's the code:
protected void listViewABC_ItemDataBound(object sender, ListViewItemEventArgs e)
{
// This stmt is used to execute the code only in case of edit
if (((ListView)(sender)).EditIndex != -1 && ((ListViewDataItem)(e.Item)).DisplayIndex == ((ListView)(sender)).EditIndex)
{
((DropDownList)(e.Item.FindControl("ddlXType"))).SelectedValue = ((MyClass)((ListViewDataItem)e.Item).DataItem).XTypeId.ToString();
((DropDownList)(e.Item.FindControl("ddlIType"))).SelectedValue = ((MyClass)((ListViewDataItem)e.Item).DataItem).ITypeId.ToString();
}
}
protected void grvSecondaryLocations_RowEditing(object sender, GridViewEditEventArgs e)
{
grvSecondaryLocations.EditIndex = e.NewEditIndex;
DropDownList ddlPbx = (DropDownList)(grvSecondaryLocations.Rows[grvSecondaryLocations.EditIndex].FindControl("ddlPBXTypeNS"));
if (ddlPbx != null)
{
ddlPbx.DataSource = _pbxTypes;
ddlPbx.DataBind();
}
.... (more stuff)
}
You can use SelectedValue:
<EditItemTemplate>
<asp:DropDownList ID="ddlPBXTypeNS"
runat="server"
Width="200px"
DataSourceID="YDS"
DataTextField="CaptionValue"
DataValueField="OID"
SelectedValue='<%# Bind("YourForeignKey") %>' />
<asp:YourDataSource ID="YDS" ...../>
</EditItemTemplate>
The checked answer from balexandre works great. But, it will create a problem if adapted to some other situations.
I used it to change the value of two label controls - lblEditModifiedBy and lblEditModifiedOn - when I was editing a row, so that the correct ModifiedBy and ModifiedOn would be saved to the db on 'Update'.
When I clicked the 'Update' button, in the RowUpdating event it showed the new values I entered in the OldValues list. I needed the true "old values" as Original_ values when updating the database. (There's an ObjectDataSource attached to the GridView.)
The fix to this is using balexandre's code, but in a modified form in the gv_DataBound event:
protected void gv_DataBound(object sender, EventArgs e)
{
foreach (GridViewRow gvr in gv.Rows)
{
if (gvr.RowType == DataControlRowType.DataRow && (gvr.RowState & DataControlRowState.Edit) == DataControlRowState.Edit)
{
// Here you will get the Control you need like:
((Label)gvr.FindControl("lblEditModifiedBy")).Text = Page.User.Identity.Name;
((Label)gvr.FindControl("lblEditModifiedOn")).Text = DateTime.Now.ToString();
}
}
}
<asp:GridView ID="GridView1" runat="server" PageSize="2" AutoGenerateColumns="false"
AllowPaging="true" BackColor="White" BorderColor="#CC9966" BorderStyle="None"
BorderWidth="1px" CellPadding="4" OnRowEditing="GridView1_RowEditing" OnRowUpdating="GridView1_RowUpdating"
OnPageIndexChanging="GridView1_PageIndexChanging" OnRowCancelingEdit="GridView1_RowCancelingEdit"
OnRowDeleting="GridView1_RowDeleting">
<FooterStyle BackColor="#FFFFCC" ForeColor="#330099" />
<RowStyle BackColor="White" ForeColor="#330099" />
<SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="#663399" />
<PagerStyle BackColor="#FFFFCC" ForeColor="#330099" HorizontalAlign="Center" />
<HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="#FFFFCC" />
<Columns>
<asp:TemplateField HeaderText="SerialNo">
<ItemTemplate>
<%# Container .DataItemIndex+1 %>.&nbsp
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="RollNo">
<ItemTemplate>
<%--<asp:Label ID="lblrollno" runat="server" Text='<%#Eval ("RollNo")%>'></asp:Label>--%>
<asp:TextBox ID="txtrollno" runat="server" Text='<%#Eval ("RollNo")%>'></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="SName">
<ItemTemplate>
<%--<asp:Label ID="lblsname" runat="server" Text='<%#Eval("SName")%>'></asp:Label>--%>
<asp:TextBox ID="txtsname" runat="server" Text='<%#Eval("SName")%>'> </asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="C">
<ItemTemplate>
<%-- <asp:Label ID="lblc" runat="server" Text='<%#Eval ("C") %>'></asp:Label>--%>
<asp:TextBox ID="txtc" runat="server" Text='<%#Eval ("C") %>'></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Cpp">
<ItemTemplate>
<%-- <asp:Label ID="lblcpp" runat="server" Text='<%#Eval ("Cpp")%>'></asp:Label>--%>
<asp:TextBox ID="txtcpp" runat="server" Text='<%#Eval ("Cpp")%>'> </asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Java">
<ItemTemplate>
<%-- <asp:Label ID="lbljava" runat="server" Text='<%#Eval ("Java")%>'> </asp:Label>--%>
<asp:TextBox ID="txtjava" runat="server" Text='<%#Eval ("Java")%>'> </asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Edit" ShowHeader="False">
<EditItemTemplate>
<asp:LinkButton ID="lnkbtnUpdate" runat="server" CausesValidation="true" Text="Update"
CommandName="Update"></asp:LinkButton>
<asp:LinkButton ID="lnkbtnCancel" runat="server" CausesValidation="false" Text="Cancel"
CommandName="Cancel"></asp:LinkButton>
</EditItemTemplate>
<ItemTemplate>
<asp:LinkButton ID="btnEdit" runat="server" CausesValidation="false" CommandName="Edit"
Text="Edit"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:CommandField HeaderText="Delete" ShowDeleteButton="True" ShowHeader="True" />
<asp:CommandField HeaderText="Select" ShowSelectButton="True" ShowHeader="True" />
</Columns>
</asp:GridView>
<table>
<tr>
<td>
<asp:Label ID="lblrollno" runat="server" Text="RollNo"></asp:Label>
<asp:TextBox ID="txtrollno" runat="server"></asp:TextBox>
</td>
<td>
<asp:Label ID="lblsname" runat="server" Text="SName"></asp:Label>
<asp:TextBox ID="txtsname" runat="server"></asp:TextBox>
</td>
<td>
<asp:Label ID="lblc" runat="server" Text="C"></asp:Label>
<asp:TextBox ID="txtc" runat="server"></asp:TextBox>
</td>
<td>
<asp:Label ID="lblcpp" runat="server" Text="Cpp"></asp:Label>
<asp:TextBox ID="txtcpp" runat="server"></asp:TextBox>
</td>
<td>
<asp:Label ID="lbljava" runat="server" Text="Java"></asp:Label>
<asp:TextBox ID="txtjava" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:Button ID="Submit" runat="server" Text="Submit" OnClick="Submit_Click" />
<asp:Button ID="Reset" runat="server" Text="Reset" OnClick="Reset_Click" />
</td>
</tr>
</table>

Resources