Click here to Skip to main content
15,883,769 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: Login Project Problems Pin
Colin Angus Mackay15-Mar-09 3:05
Colin Angus Mackay15-Mar-09 3:05 
AnswerRe: Login Project Problems Pin
StarTrekCafe15-Mar-09 13:41
StarTrekCafe15-Mar-09 13:41 
Questionproblem in cast value from money to decimal Pin
Sneha Bisht14-Mar-09 23:34
Sneha Bisht14-Mar-09 23:34 
AnswerRe: problem in cast value from money to decimal Pin
Colin Angus Mackay15-Mar-09 3:10
Colin Angus Mackay15-Mar-09 3:10 
Questionasp.net grid view [modified] Pin
PleaseHelpCP14-Mar-09 22:12
PleaseHelpCP14-Mar-09 22:12 
AnswerRe: asp.net grid view Pin
Christian Graus14-Mar-09 22:36
protectorChristian Graus14-Mar-09 22:36 
GeneralRe: asp.net grid view Pin
Alok Sharma ji15-Mar-09 17:55
Alok Sharma ji15-Mar-09 17:55 
Questionproblem in updating database via datagrid Pin
rosae61914-Mar-09 21:28
rosae61914-Mar-09 21:28 
hello sir/madam
i have following code for updating database via datagrid control,,but it produces an error..can anybody tell me how to deal with this kind of error..


]]>

]]>


SqlConnection connector = new SqlConnection(@"Server=localhost;Integrated Security=SSPI;Database=cms");
String strsql;
void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
BindDataGrid();

}
void BindDataGrid()
{
SqlCommand cmdsql = new SqlCommand("Select * from studentmarksentry", connector);
connector.Open();
unittest1marksentry_datagrid.DataSource = cmdsql.ExecuteReader();
unittest1marksentry_datagrid.DataBind();
connector.Close();

}

void CancelCommand(Object sender, DataGridCommandEventArgs e)
{
unittest1marksentry_datagrid.EditItemIndex = -1;
BindDataGrid();
}
void EditCommand(Object sender, DataGridCommandEventArgs e)
{
unittest1marksentry_datagrid.EditItemIndex = e.Item.ItemIndex;
BindDataGrid();

}
void UpdateCommand(Object sender, DataGridCommandEventArgs e)
{
int regd_num;

String txtvalueholder;

if (IsValid)
{
regd_num=(int)unittest1marksentry_datagrid.DataKeys[e.Item.ItemIndex];
TextBox txtmarksentry = (TextBox)e.Item.FindControl("txtmarksentry");
txtvalueholder = txtmarksentry.Text;
strsql = "update studentmarksentry set MarksObtained=@marksentry where Regdno=@register";
SqlCommand cmdsql = new SqlCommand(strsql, connector);
cmdsql.Parameters.Add("@marksentry", txtvalueholder);
cmdsql.Parameters.Add("@register", regd_num);
connector.Open();
cmdsql.ExecuteNonQuery();
connector.Close();
unittest1marksentry_datagrid.EditItemIndex = -1;
BindDataGrid();

}

}






<title>Unit-Test 1 marks Entry form



<asp:datagrid id="unittest1marksentry_datagrid" autogeneratecolumns="false" oncancelcommand="CancelCommand" oneditcommand="EditCommand" xmlns:asp="#unknown">
OnUpdateCommand="UpdateCommand" runat="server">
<columns> <asp:boundcolumn headertext="Register No" datafield="Regdno" readonly="true">
<asp:boundcolumn headertext="First Name" datafield="First name" readonly="true">
<asp:boundcolumn headertext="Middle Name" datafield="Middle name" readonly="true">
<asp:boundcolumn headertext="Last Name" datafield="Last name" readonly="true">
<asp:templatecolumn>
<headertemplate>
Marks Obtained
<itemtemplate>
<%#DataBinder.Eval(Container.DataItem,"MarksObtained") %>

<edititemtemplate>
<asp:textbox id="txtmarksentry" text="<%#DataBinder.Eval(Container.DataItem," marksobtained")="" %&gt;"="">
runat="server">
<asp:comparevalidator id="unittest1marksentry_comparevalidator" controltovalidate="txtmarksentry">
Display="Dynamic" Text="must be a number" Operator="DataTypeCheck" Type="Integer"
runat="Server">


<asp:editcommandcolumn edittext="Edit" updatetext="Update" canceltext="Cancel">




here my database name is cms and try to update the marks obatined column but i get following error
:Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
ok
waiting for the reply.
AnswerRe: problem in updating database via datagrid Pin
Christian Graus14-Mar-09 21:44
protectorChristian Graus14-Mar-09 21:44 
Questioncan onblur method of javascript is also possible in c#.net scripting i am trying it but it not works have any similar method there ? Pin
Alok Sharma ji14-Mar-09 11:49
Alok Sharma ji14-Mar-09 11:49 
AnswerRe: can onblur method of javascript is also possible in c#.net scripting i am trying it but it not works have any similar method there ? Pin
Christian Graus14-Mar-09 12:16
protectorChristian Graus14-Mar-09 12:16 
GeneralRe: can onblur method of javascript is also possible in c#.net scripting i am trying it but it not works have any similar method there ? Pin
Alok Sharma ji14-Mar-09 15:28
Alok Sharma ji14-Mar-09 15:28 
GeneralRe: can onblur method of javascript is also possible in c#.net scripting i am trying it but it not works have any similar method there ? Pin
N a v a n e e t h14-Mar-09 16:32
N a v a n e e t h14-Mar-09 16:32 
GeneralRe: can onblur method of javascript is also possible in c#.net scripting i am trying it but it not works have any similar method there ? Pin
Christian Graus14-Mar-09 21:43
protectorChristian Graus14-Mar-09 21:43 
GeneralRe: can onblur method of javascript is also possible in c#.net scripting i am trying it but it not works have any similar method there ? Pin
N a v a n e e t h15-Mar-09 3:29
N a v a n e e t h15-Mar-09 3:29 
GeneralRe: can onblur method of javascript is also possible in c#.net scripting i am trying it but it not works have any similar method there ? Pin
Abhishek Sur14-Mar-09 21:58
professionalAbhishek Sur14-Mar-09 21:58 
AnswerRe: can onblur method of javascript is also possible in c#.net scripting i am trying it but it not works have any similar method there ? Pin
Alok Sharma ji15-Mar-09 17:36
Alok Sharma ji15-Mar-09 17:36 
QuestionLinkButton cann't work [modified] Pin
sohighthesky14-Mar-09 6:14
sohighthesky14-Mar-09 6:14 
AnswerRe: LinkButton cann't work Pin
N a v a n e e t h14-Mar-09 6:22
N a v a n e e t h14-Mar-09 6:22 
AnswerRe: LinkButton cann't work Pin
Christian Graus14-Mar-09 8:11
protectorChristian Graus14-Mar-09 8:11 
QuestionResize gridview column width dynamically like component art grid Pin
ashishparihar131014-Mar-09 3:00
ashishparihar131014-Mar-09 3:00 
AnswerRe: Resize gridview column width dynamically like component art grid Pin
N a v a n e e t h14-Mar-09 6:21
N a v a n e e t h14-Mar-09 6:21 
QuestionAccessing listitem object collection... Pin
Radiv Jeshya14-Mar-09 2:48
Radiv Jeshya14-Mar-09 2:48 
AnswerRe: Accessing listitem object collection... Pin
N a v a n e e t h14-Mar-09 6:17
N a v a n e e t h14-Mar-09 6:17 
QuestionDisplay data according to cultural settings in SQL Report Pin
Shivan Nandan14-Mar-09 0:59
Shivan Nandan14-Mar-09 0:59 

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.