Hi; have a gridview with a list of students (id, name ...) I want to find the student with id = 1111 for example, how do that? thanks
amina89
Posts
-
Searching the numeric value in a gridview -
Searching the numeric value in a gridviewHi; I can not search for numeric values in a gridview. searching works just for string. can you help me please.Thanks
-
Retrieve the value of a control of the master pageHi; I try:
Control masterControl = Master.FindControl("TextBox1");
if(masterControl != null)
{
string textToCopy = (TextBox)masterControl.Text;
TextBox2.Text = textToCopy;
} else{TextBox2.Text="rr";
}result:TextBox2 is empty :(
-
Retrieve the value of a control of the master pagehello; the value of Textbox1 is 2010/2011 is retrieved from the database but the problem is to pass it to TextBox2. Thank
-
Retrieve the value of a control of the master pageHello; In the master page of my site I have a textbox that displays the school year, to recover the value of textbox in other pages I used: page.master.cs
protected void Page_Load(object sender, EventArgs e) { Label13.Text = Convert.ToString(DateTime.Now); // SqlConnection maConnexionSQLsrv = new SqlConnection(@"Data Source=.\SQLEXPRESS;UID=sa;Password=forChariaa3*;Initial Catalog=scolarite"); SqlConnection myConnection = new SqlConnection(ConnectionString); myConnection.Open(); String maRequete = "select ann_uni as [p1]from annee where @param between date_debut and date_fin"; SqlCommand myCommand = new SqlCommand(maRequete, myConnection); myCommand.Parameters.Add(new SqlParameter("@param", SqlDbType.DateTime)); myCommand.Parameters["@param"].Value = Label13.Text; SqlDataReader drr2 = myCommand.ExecuteReader(); while (drr2.Read()) { Textbox1.Text = drr2["p1"].ToString(); } drr2.Close(); } private string ConnectionString { get { string connectionString = (@"Data Source=.\SQLEXPRESS;UID=sa;Password=*****;Initial Catalog=bd1"); // string connectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString; return connectionString; } } public string ContentTextBoxOfMasterPage { get { return Textbox1.Text; } }
defaul2.aspx<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" Title="Page sans titre" %> <%@ MasterType virtualPath="~/MasterPage.master"%> <asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server"> </asp:Content> <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"> <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox></asp:Content>
Default2.aspx.csprotected void Page_Load(object sender, EventArgs e) { TextBox2.Text = Master.ContentTextBoxOfMasterPage; }
MasterPage.masterBut TextBox2 is empty. thank you
-
After loging open the file for user connnected [modified]Hi, I dont work with vb.net I added this code in the file Default.aspx.vb
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load fldRoles.Text = String.Format("User {0} has in the following roles:", My.User.Name) For Each arole As String In Roles.GetRolesForUser(My.User.Name) fldRoles.Text += String.Format("<br/>{0}", arole) Next If My.User.IsInRole("AdminModule1") Then Response.Redirect("adminM1/nn.aspx") Response.End() ElseIf My.User.IsInRole("AdminModule2") Then Response.Redirect("adminM2/nn.aspx") Response.End() ElseIf My.User.IsInRole("AdminModule3") Then Response.Redirect("adminM3/nn.aspx") Response.End() End If End Sub
but no result Thanks -
After loging open the file for user connnected [modified]Hi, I used the code for this pageDeveloping custom ASP.NET Membership and Role providers reading users from custom section in the web.config[^] [] modified code that supports multiple roles per user I have several folders one folder for each role I do not know how to modify the code to open the file that corresponds to user connected and not the default.aspx page. Thanks
modified on Tuesday, February 1, 2011 6:18 AM
-
securite management reviewHi ; 1-files visible to the people of Registration Service 2-files for teachers: semester 1 file visible to teachers of Module 1 file visible to teachers of Module2 file visible to teachers of Module 3 semester 2 file visible to teachers of Module 4 file visible to teachers of modules 5 file visible to teachers of Module 6 3- the other file are visible to all users Thanks
-
securite management reviewhello I work on a intranet site of management review, to insert the markes I have files for each module I want only the professor of module has the right access to his file.How ? Thanks
-
Gridview update numeric valuesHi, I have any error message(unless the marks(note) field is empty) but the code does not update data ; Thanks .
-
Gridview update numeric valueshello, I want insert student markes by aonce click using a gridview and this code:
private void Update() { string cmd = @"UPDATE EXAMEN set NOTE= CASE WHEN CODE_MATIERE = '1' and @note1 =99 then '0' when CODE_MATIERE = '1' and @note1 <>99 then @note1 WHEN CODE_MATIERE = '2' and @note2 ='99' then '0' when CODE_MATIERE = '2' and @note2 <>99 then @note2 END, PRESENCE= CASE WHEN CODE_MATIERE = '1' and @note1 =99 then 'TRUE' when CODE_MATIERE = '2' and @note2 ='99' then 'TRUE' else 'FALSE' end WHERE NUM_INSCRIPTION = @num;"; float note1, note2; string num; SqlCommand myCommand; SqlParameter param1, param2, param3; using (SqlConnection myConnection = new SqlConnection(ConnectionString)) { myConnection.Open(); foreach (GridViewRow row in GridView1.Rows) { note1 = float.Parse(((TextBox)row.FindControl("tmoy1")).Text); note2 = float.Parse(((TextBox)row.FindControl("tmoy4")).Text); num = ((Label)row.FindControl("lblUserID1")).Text; myCommand = new SqlCommand(cmd, myConnection); param1 = new SqlParameter("num", SqlDbType.VarChar, 4); param1.Value = num; myCommand.Parameters.Add(param1); param2 = new SqlParameter("note1", SqlDbType.Float, 2); param2.Value = note1; myCommand.Parameters.Add(param2); param3 = new SqlParameter("note2", SqlDbType.Float, 2); param3.Value = note2; myCommand.Parameters.Add(param3); myCommand.ExecuteNonQuery(); } } myConnection.Close(); }
but the code not work I tried the float and decimal and money for the type of note I tried float.parse, Decimal.Parse, convert.todecimal the code multiplies the values of the first row by 2 for each click on update button bizarre . help me please,thanks Écouter Lire phonétiquement
-
Update all gridview rows at onceIt works thaaaaaaaaaaaaaaaaaaanks merciiiiiiiiiiii phil.o.
-
Update all gridview rows at onceHi, the program does not read :((TextBox)row.FindControl("note2")).Text; it reads ((Label)row.FindControl("lblUserID1")).Text; I think the problem come from there but I do not know how to correct that. Thanks
-
Update all gridview rows at onceHi, Thank you very much phil. the program does not read TexBox of the gridview it returns me this message 'The format of the input string is incorrect.' for this line : note1 = float.Parse(((TextBox)row.FindControl("note1")).Text); when I debug I found that the value of note1 is 0.0 while I typed 13. Thanks.
-
Update all gridview rows at onceHi; Thak you phil.o :) I tried using a parameterized query but it does not work:It update with zero all marks
foreach (GridViewRow row in GridView1.Rows) { TextBox notem1 = row.FindControl("note1") as TextBox; TextBox notem2 = row.FindControl("note2") as TextBox; Label num = row.FindControl("lblUserID1") as Label; SqlConnection myConnection = new SqlConnection(ConnectionString); SqlCommand myCommand = new SqlCommand( "UPDATE EXAMEN " + "SET NOTE = " + "(CASE " + "WHEN CODE_MATIERE = '111' then @note1 " + "WHEN CODE_MATIERE = '112' then @note2 " + "END) " + "WHERE NUM_INSCRIPTION = @num;" , myConnection); myCommand.Parameters.Add(new SqlParameter("@num", SqlDbType.VarChar, 4)); myCommand.Parameters["@num"].Value = num.Text; myCommand.Parameters.Add(new SqlParameter("@note1", SqlDbType.Float, 2)); myCommand.Parameters["@note1"].Value = notem1.Text.Replace(",", "."); myCommand.Parameters.Add(new SqlParameter("@note2", SqlDbType.Float, 2)); myCommand.Parameters["@note2"].Value = notem2.Text.Replace(",", "."); myConnection.Open(); myCommand.ExecuteNonQuery(); myConnection.Close(); }
modified on Thursday, October 14, 2010 6:21 AM
-
Update all gridview rows at onceHi, when I execute this code i get the following error:Incorrect syntax near the keyword When.
StringBuilder sb = new StringBuilder();
foreach (GridViewRow row in GridView1.Rows)
{string note1 = (row.FindControl("note1") as TextBox).Text.Replace(",", "."); string note2 = (row.FindControl("note2") as TextBox).Text.Replace(",", "."); string userID = (row.FindControl("lblUserID1") as Label).Text; sb.AppendFormat( @"UPDATE EXAMEN SET NOTE = case when
CODE_MATIERE ='111' then {0}
when CODE\_MATIERE ='112' then {1} END where NUM\_INSCRIPTION = {2} ; ", note1, note2, userID); }
</pre>
-
Gridview with rows calculThanks all ; I still have the same error. I forgot to say that the gridview is in edit mode for columns -exam_mark1 ,-exam_mark2 and I do not know if this is the cause.
<asp:GridView ID="GridView1" runat="server" AllowSorting="True" AutoGenerateColumns="False" BackColor="White" BorderColor="#CCCCCC" BorderWidth="1px" CellPadding="4" CssClass="th" DataKeyNames="NUM_INSCRIPTION" Width ="60%" Height="9%" PagerStyle-CssClass="note" Style="position: absolute; left: 126px; top: 159px;" > <FooterStyle BackColor="White" ForeColor="#000066" /> <RowStyle ForeColor="#000066" /> <SelectedRowStyle BackColor="#669999" Font-Bold="True" ForeColor="White" /> <PagerStyle BackColor="White" CssClass="note" ForeColor="#000066" HorizontalAlign="Left" /> <HeaderStyle BackColor="#006699" Font-Bold="True" ForeColor="White" /> <Columns> <asp:TemplateField HeaderText="IDStudent"> <ItemStyle CssClass="td00" /> <ItemTemplate> <asp:Label ID="lblUserID1" runat="server" Text='<%# Eval("NUM_INSCRIPTION") %>'></asp:Label> <itemstyle cssclass="td00" /> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="StudentName"> <ItemStyle CssClass="td01" /> <ItemTemplate> <asp:Label ID="lblUserID2" runat="server" Text='<%# Eval("NOM_PRENOM_ETUDIANT_ARABE") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="mark1"> <ItemTemplate> <asp:Label ID="lblLastName1" runat="server" Text='<%# Eval("111") %>' Visible='<%# !(bool) IsInEditMode %>'></asp:Label> <asp:TextBox ID="moyt1" runat="server" Text='<%# Eval("111") %>' Visible='<%# IsInEditMode %>'></asp:TextBox> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="mark2"> <ItemStyle CssClass="td02" /> <ItemTemplate>
-
Gridview with rows calculHello I have a gridview with this form ID_student -------exam_mark1 ------exam_mark2-----average to calculate the average score I used this code
double average = 0; foreach (GridViewRow MRow in GridView1.Rows) { average = double.Parse(MRow.Cells[2].Text ) + double.Parse(MRow.Cells[3].Text); average = average / 2; MRow.Cells[4].Text = moyenne.ToString(); }
but it returns me the following error: The format of the input string is incorrect. Help me ,thanks -
Manage role is this correct?Thanks Mark Nischalke, I still have the same problem(with the previous link)and even using visual studio 2008 menu web site / asp.net configuration...Username / password incorrect. Please try again. i dont know if i have a problem in visual studio or what? thanks (sorry i dont speak english well)
-
Manage role is this correct?Thanks a lot Mark Nischalke and Jinal Desai - LIVE, I used the link but when I login I have this message: Username / password incorrect. Please try again.(password and database connection are just) I think that I have a problem with the web config. Mark Nischalke I do not understand:Role based security is also available out of the box with ASP.NET. thanks
modified on Monday, July 12, 2010 11:20 AM