Click here to Skip to main content
15,897,291 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: "asp:fileupload" control is not working Pin
Hampden Tech24-Jan-09 2:41
Hampden Tech24-Jan-09 2:41 
Questionbest between VB and c# Pin
souravghosh1823-Jan-09 19:40
souravghosh1823-Jan-09 19:40 
AnswerRe: best between VB and c# Pin
Colin Angus Mackay24-Jan-09 1:12
Colin Angus Mackay24-Jan-09 1:12 
AnswerRe: best between VB and c# Pin
Wendelius24-Jan-09 5:07
mentorWendelius24-Jan-09 5:07 
QuestionProblem Regarding Preventing Postback Pin
ais0723-Jan-09 17:21
ais0723-Jan-09 17:21 
AnswerRe: Problem Regarding Preventing Postback Pin
Nishant Singh23-Jan-09 22:50
Nishant Singh23-Jan-09 22:50 
GeneralRe: Problem Regarding Preventing Postback Pin
ais0723-Jan-09 22:53
ais0723-Jan-09 22:53 
QuestionUpdate rows in a gridview Pin
Cyberpulse23-Jan-09 15:36
Cyberpulse23-Jan-09 15:36 
I have a gridview that I am populating with data based on user values in a textbox from the code behind. I have the gridview working correctly upto the point of displaying relevant data, making the selected row editable when the 'edit' link next to the corresponding row is clicked and cancelling the editable row so that reverts back to display mode. The problem is updating. How do I save the changes made to a specific row in edit mode once I hit the update link. My code is as follows:-



1 public partial class UserLockouts : System.Web.UI.Page
2 {
3 public SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["xyz"].ConnectionString);
4 public static int uniqueStoreId = 0;
5 public static int storeId = 0;
6 public static int userId = 0;
7 protected void Page_Load(object sender, EventArgs e)
8 {
9
10 }
11
12 protected void btn_Search_Click(object sender, EventArgs e)
13 {
14 bindGridView();
15 }
16
17 protected void bindGridView()
18 {
19 if (tb_UniqueSN.Text != string.Empty)
20 {
21 conn.Open();
22 string strSQL = "SELECT [StoreId] FROM [ac_StoreSettings] WHERE ([FieldValue] ='" + tb_UniqueSN.Text + "')";
23 SqlCommand cmd = new SqlCommand(strSQL, conn);
24 Object myData = cmd.ExecuteScalar();
25 uniqueStoreId = Int32.Parse(myData.ToString());
26 storeId = uniqueStoreId;
27 conn.Close();
28 }
29
30 else if (tb_StoreID.Text != string.Empty)
31 {
32 storeId = Int32.Parse(tb_StoreID.Text);
33 }
34
35 else if (tb_UserID.Text != string.Empty)
36 {
37 conn.Open();
38 string strSQL = "SELECT [UserId], [IsLockedOut] FROM [ac_Users] WHERE ([UserId] =" + Int32.Parse(tb_UserID.Text) + ")";
39 SqlCommand cmd = new SqlCommand(strSQL, conn);
40 DataTable dt = new DataTable();
41 SqlDataAdapter sqlAdapter = new SqlDataAdapter(null, conn);
42 sqlAdapter.SelectCommand = cmd;
43 sqlAdapter.Fill(dt);
44 conn.Close();
45 try
46 {
47 grd_Users.DataSource = dt.DefaultView;
48 grd_Users.DataBind();
49 pnl_Users.Visible = true;
50 }
51 catch (Exception ex)
52 {
53 AuctivaUtils2.AuctivaLogger.WriteErrorEntry(ex.Message, AuctivaUtils2.eAuctivaLogFile.General);
54 }
55 finally
56 {
57 conn.Close();
58 }
59 }
60
61 if (storeId != 0)
62 {
63 conn.Open();
64 string strSQL = "SELECT [UserId], [IsLockedOut] FROM [ac_Users] WHERE ([StoreId] ='" + storeId + "')";
65 SqlCommand cmd = new SqlCommand(strSQL, conn);
66 DataSet ds = new DataSet();
67 SqlDataAdapter sqlAdapter = new SqlDataAdapter(null, conn);
68 sqlAdapter.SelectCommand = cmd;
69 sqlAdapter.Fill(ds);
70 conn.Close();
71 try
72 {
73 grd_Users.DataSource = ds;
74 grd_Users.DataBind();
75 pnl_Users.Visible = true;
76 }
77 catch (Exception ex)
78 {
79 AuctivaUtils2.AuctivaLogger.WriteErrorEntry(ex.Message, AuctivaUtils2.eAuctivaLogFile.General);
80 }
81 finally
82 {
83 conn.Close();
84 }
85 }
86 }
87
88 protected void grd_Users_RowEditing1(object sender, GridViewEditEventArgs e)
89 {
90 grd_Users.EditIndex = e.NewEditIndex;
91 bindGridView();
92 }
93
94 protected void grd_Users_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
95 {
96 grd_Users.EditIndex = -1;
97 bindGridView();
98 }
99
100 }
101 }



The markup for my gridview is as follows:-

1 <asp:panel id="pnl_Users" runat="server" visible="False" xmlns:asp="#unknown">
2 <asp:gridview id="grd_Users" runat="server">
3 onrowediting="grd_Users_RowEditing1" AutoGenerateEditButton="True"
4 onrowcancelingedit="grd_Users_RowCancelingEdit">
5
AnswerRe: Update rows in a gridview Pin
N a v a n e e t h23-Jan-09 16:33
N a v a n e e t h23-Jan-09 16:33 
QuestionHow to set a session variable to selected row value Pin
cubangt23-Jan-09 11:55
cubangt23-Jan-09 11:55 
AnswerRe: How to set a session variable to selected row value Pin
Not Active23-Jan-09 14:13
mentorNot Active23-Jan-09 14:13 
Questionxsd serialization question Pin
Member 391904923-Jan-09 10:54
Member 391904923-Jan-09 10:54 
QuestionHow to redirect to the default.aspx page ? Pin
David Mujica23-Jan-09 10:43
David Mujica23-Jan-09 10:43 
AnswerRe: How to redirect to the default.aspx page ? Pin
Talal Sultan23-Jan-09 11:05
Talal Sultan23-Jan-09 11:05 
AnswerRe: How to redirect to the default.aspx page ? Pin
Rutvik Dave23-Jan-09 11:17
professionalRutvik Dave23-Jan-09 11:17 
GeneralRe: How to redirect to the default.aspx page ? Pin
N a v a n e e t h23-Jan-09 16:26
N a v a n e e t h23-Jan-09 16:26 
GeneralRe: How to redirect to the default.aspx page ? Pin
Rutvik Dave24-Jan-09 3:56
professionalRutvik Dave24-Jan-09 3:56 
AnswerRe: How to redirect to the default.aspx page ? Pin
Hampden Tech24-Jan-09 2:44
Hampden Tech24-Jan-09 2:44 
AnswerIt works - Thanks Pin
David Mujica25-Jan-09 10:39
David Mujica25-Jan-09 10:39 
Questionhw to create color pallette or change color of text in creating template ? Pin
teju gadekar23-Jan-09 7:14
teju gadekar23-Jan-09 7:14 
AnswerRe: hw to create color pallette or change color of text in creating template ? Pin
Not Active23-Jan-09 7:30
mentorNot Active23-Jan-09 7:30 
QuestionNeed help obtaing info from an array Pin
BPatt23-Jan-09 7:01
BPatt23-Jan-09 7:01 
AnswerRe: Need help obtaing info from an array Pin
Not Active23-Jan-09 7:28
mentorNot Active23-Jan-09 7:28 
QuestionHow to display a image from database in a dridview? Pin
Meax23-Jan-09 5:18
Meax23-Jan-09 5:18 
AnswerRe: How to display a image from database in a dridview? Pin
Abhijit Jana23-Jan-09 5:30
professionalAbhijit Jana23-Jan-09 5:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.