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
Rashid Khan
NA
159
0
RowUpdating in gridview
Apr 20 2010 10:01 AM
Hii frnds thnx for reply on my last post. i sort out the issue, while using datakeys.
but now facing problem in row updating.
cant able to assign values which will be updated.
i using layers (BusinessEntity,Logic nd dataaccess)
so here is my code
binding data in gridview
private void BindGrid()
{
UserInfoBE objUserBE = new UserInfoBE();
objUserBE.EmailId = lblID.Text;
UserInfoBL objUserBL = new UserInfoBL();
GridView1.DataSource = objUserBL.SelectAllUserInfo(objUserBE);
GridView1.DataBind();
}
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
UserInfoBE objUserBE = new UserInfoBE();
objUserBE.EmailId =((TextBox)GridView1.Rows[e.RowIndex].Cells[2]).Text;
objUserBE.FirstName = ((TextBox)GridView1.Rows[e.RowIndex].Cells[2]).Text;
objUserBE.LastName = ((TextBox)GridView1.Rows[e.RowIndex].Cells[2]).Text;
objUserBE.Mobile = ((TextBox)GridView1.Rows[e.RowIndex].Cells[2]).Text;
objUserBE.Address =((TextBox)GridView1.Rows[e.RowIndex].Cells[2]).Text;
UserInfoBL objUserBL = new UserInfoBL();
if (objUserBL.InsertUpdateUserInfo(objUserBE) > 0)
{
GridView1.EditIndex = -1;
BindGrid();
lblmsg.Text = "Update";
}
}
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
{
GridView1.EditIndex = e.NewEditIndex;
BindGrid();
}
i know where i m making mistake,. i m using itemtemplate field where i set textboxes. nd labels.
here is the structure
<asp:Label ID="lblID" runat="server" Text="" Visible="false"></asp:Label>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
PageSize="1" DataKeyNames="EmailId,FirstName,LastName,Mobile,Address"
onrowediting="GridView1_RowEditing" onrowupdating="GridView1_RowUpdating"
AutoGenerateEditButton="True">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<table cellpadding="0" cellspacing="0" class="style1">
<tr>
<td style="width: 88px">
<asp:Label ID="lblEmailId" runat="server" Text="EmailId" Enabled="false"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtEmailId" runat="server"
Width="150px" Enabled="False" Text='<%# Bind("EmailId") %>'></asp:TextBox>
</td>
</tr>
<tr>
<td style="width: 88px">
<asp:Label ID="lblFirstName" runat="server" Text="First Name"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtFirstName" runat="server" Text='<%# Bind("FirstName") %>'></asp:TextBox>
</td>
</tr>
<tr>
<td style="width: 88px">
<asp:Label ID="lblLastName" runat="server" Text="Last Name"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtLastName" runat="server" Text='<%# Bind("LastName") %>'
Width="150px"></asp:TextBox>
</td>
</tr>
<tr>
<td style="width: 88px">
<asp:Label ID="lblMobile" runat="server" Text="Mobile"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtMobile" runat="server" Text='<%# Bind("Mobile") %>'
Width="150px"></asp:TextBox>
</td>
</tr>
<tr>
<td style="width: 88px">
<asp:Label ID="lblAddress" runat="server" Text="Address"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtAddress" runat="server" Text='<%# Bind("Address") %>'
Width="150px"></asp:TextBox>
</td>
</tr>
<tr>
<td>
</td>
</tr>
<tr>
<td style="width: 88px">
</td>
<td>
<asp:Button ID="btnUpdate" runat="server" Text="Update" />
</td>
</tr>
<tr>
<td style="width: 88px">
</td>
<td>
</td>
</tr>
</table>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
how to give values to business entity layer.
i cant send code file please tell me possible changes so tht i can i assign those values field to BE.
thanks
Reply
Answers (
3
)
Page.Isvalid is considering disabled Validation control also !
How to load page without load master page