Quantcast
Channel: CSharp Forum Latest Questions
Viewing all 32756 articles
Browse latest View live

Radio Button Values into SQL

$
0
0
Hello Everyone. 

Really hope someone can help with this, as it is for a exam on monday! :) 

I got a page, where there are 40 radio buttons: 
My big problem is, how do i select the checked once, and insert them into database? 

Nestedrepeater.aspx
__________
<!-- start parent repeater -->
<asp:repeater id="parentRepeater" runat="server">
   <itemtemplate>
      <b>
          <%# DataBinder.Eval(Container.DataItem,"QuestionsName") %>
      </b><br>

      <!-- start child repeater -->
      <asp:repeater id="childRepeater" datasource='<%# ((DataRowView)Container.DataItem)
      .Row.GetChildRows("myrelation") %>' runat="server">

         <itemtemplate>

             <asp:RadioButton GroupName="TEST"  ID="RadioButton1" Text='<%# DataBinder.Eval(Container.DataItem, "[\"QuizAnswer\"]")%>' 
                SelectedValue='<%# DataBinder.Eval(Container.DataItem, "[\"QuizAnswerid\"]")%>' runat="server" TextAlign="Right" /> <br />
             <asp:HiddenField ID="HiddenField1" Value='<%# DataBinder.Eval(Container.DataItem, "[\"Correct\"]")%>' runat="server" />
         </itemtemplate>
       
      </asp:repeater>
      <!-- end child repeater -->
           <br />
             <br />
   </itemtemplate>
</asp:repeater>
<!-- end parent repeater -->


Nedstedrepeater.aspx.cs
_______________________
using System;
using System.Data;
using System.Data.SqlClient;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace NestedRepeater
{
    public partial class NestedRepeater : System.Web.UI.Page
    {

        public NestedRepeater()
        {
            Page.Init += new System.EventHandler(Page_Init);
        }
        public void Page_Load(object sender, EventArgs e)
        {

        
         

            //Create the connection and DataAdapter for the Authors table.
            SqlConnection cnn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["QuizDataConnectionString1"].ConnectionString);
            SqlDataAdapter cmd1 = new SqlDataAdapter("select * from Questions", cnn);

            //Create and fill the DataSet.
            DataSet ds = new DataSet();
            cmd1.Fill(ds, "Questions");

            //Create a second DataAdapter for the Titles table.
            SqlDataAdapter cmd2 = new SqlDataAdapter("select * from QuizAnswers", cnn);
            cmd2.Fill(ds, "QuizAnswers");

            //Create the relation bewtween the Authors and Titles tables.
            ds.Relations.Add("myrelation",
            ds.Tables["Questions"].Columns["Questionsid"],
            ds.Tables["QuizAnswers"].Columns["QuestionID"]);

            //Bind the Authors table to the parent Repeater control, and call DataBind.
            parentRepeater.DataSource = ds.Tables["Questions"];
            Page.DataBind();

            //Close the connection.
            cnn.Close();
        }
        private void Page_Init(object sender, EventArgs e)
        {
            InitializeComponent();
        }
        private void InitializeComponent()
        {
            this.Load += new System.EventHandler(this.Page_Load);
        }

       
        // Event when button is cliced
        protected void Button1_Click(object sender, EventArgs e)
        {
            SqlConnection cnn = new SqlConnection();
        cnn.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["QuizDataConnectionString1 "].ConnectionString;
        cnn.Open();
        SqlCommand cmd = new SqlCommand();
        cmd.CommandText = "select * from  Answers";
        cmd.Connection = cnn;
        SqlDataAdapter da = new SqlDataAdapter();
        da.SelectCommand = cmd;
        DataSet ds = new DataSet();
        da.Fill(ds, " Answers ");
        SqlCommandBuilder cb = new SqlCommandBuilder(da);
        DataRow drow = ds.Tables["Answers"].NewRow();
        drow["Name"] = Name.Text;
       drow["Telephone"] = Telephone.Text;
              drow["Email"] = Mail.Text;
// As you can see here, i got the field ready, just need to find the selected data to insert. 
              drow["Qs1"] = TextBox1.Text;
              drow["Qs2"] = TextBox1.Text;
              drow["Qs3"] = TextBox1.Text;
              drow["Qs4"] = TextBox1.Text;
              drow["Qs5"] = TextBox1.Text;
              drow["Qs6"] = TextBox1.Text;
              drow["Qs7"] = TextBox1.Text;
              drow["Qs8"] = TextBox1.Text;
              drow["Qs9"] = TextBox1.Text;
              drow["Qs10"] = TextBox1.Text;
              drow["Total_Correct_Answers"] = TextBox1.Text;
 
        ds.Tables["Answers "].Rows.Add(drow);
        da.Update(ds, " Answers ");
        string script = @"<script language=""javascript"">
        alert('Information have been Saved Successfully.......!!!!!.');
       </script>;";
        Page.ClientScript.RegisterStartupScript(this.GetType(), "myJScript1", script);
    }


        }
}
        }




How to make JSTREE Navigate to another page in MVC3 (Razor)?

$
0
0

Hi,

I am using the example in the following link to create a Treeview to show a list of Managers, Employees and so on in an MVC3 (Razor) page. -

http://www.techiesweb.net/asp-net-mvc3-tree-view-with-jstree/#comment-830


what I am trying to do is -

when a user clicks on the Name of a Manager or an Employee, it should either show the "ID" of that employee in a Text Box in the same page (.cshtml) orNavigate to another page where the user can see the profile of the selected employee. Can anyone please help me to do it?

I can display the employee names in a TreeView using JSTree; but JSTree does not allow me to Navigate to another page.

Thanks

Using XSD.exe generated classes to create xml documents

$
0
0
I got excited about the XSD.exe tool to create c# classes from a xsd file.

It allowed me to use the XMLSerializer to generate xml documents that must be validated against rather complicated xsd.

I notice that all the types used in the xsd were converted to strings in the c# classes.  This means the classes will not be able to 
validate my xml documents to insure xml element types such as "unsignedByte-or-empty".  

Does anyone have this experience regarding complex xsd files?  

My goal is to pull all the data required for each xml document into memory from a sql server DB.  
Then I hoping to use the declarations in the classes that XSD.exe generates to guide any data conversions required 
before serializing the output to an xml file.

Now it seems I must validate the xml data types before the data is converted to strings and serialized.

I keep reading how useful XSD.exe can be, but perhaps not for my project?
Thanks in advance for any insight offered,
Chris. 

how to display the rid view records using chart

$
0
0

 Gridview records as follows;


in gridivew records as follows;


  Facname    Rating

   Ram          Excellent
   Gopi          Good
  Suresh       Fair
  Vijay          Poor
 


i want to show the above gridview record to be displayed in the Chart.


for that how can i write the code.

please help me.

Regards,
Narasiman P.


.Net

$
0
0
is there any future in .Net technology ???

How do I make the picture form. how to start it. Is there an

$
0
0
How do I makethe pictureform. how tostartit. Is there anyexample ofit.


Print Button in Windows Forms

$
0
0
How to apply Printing function in Window Form.?

database

$
0
0
how can i authenticate that the given data doesn't exist in database !!!

MultiThreading PictureBox- Loses image after time?

$
0
0
First off let me state that I put this in multi-threading because it is indeed a threaded process that's producing this problem.

Alright, I have a basic StretchBlt function, running in a separate thread, that's ripping a screen image to Bitmap() and throwing it in a PictureBox.  (Delegated, of course)

This is working fine at 60+fps for anywhere from about 2-5 minutes at which point the PictureBox 'loses' its image (white square with red X through it).  Nothing changes internally, it just seems after several hundred updates, the PictureBox simply gives up.


I'm wondering if I'm running into an overflow problem with the Control or if there's some bizarre way I'm running 'out of sync' with my thread vs GUI thread?


I'll pastebin a shortened sample below.. Threading a function to StretchBlt and inlining the delegate to update the PictureBox.

(Sorry in advance for any foul coding practices, this is merely my proof of concept code, it'll be rewritten and cleaned later.)

        private void manualScreenCap(Stopwatch sw)
        {
            GetWindowRect(wndLiveHWND, ref gRect);


            IntPtr bufferHdc;


            Bitmap _bmpBuffer = new Bitmap(400, 300);
            Graphics g = Graphics.FromImage(_bmpBuffer);


            IntPtr tgtHdc = GDI32.GetWindowDC(wndLiveHWND);






            int tgtWidth = gRect.Right - gRect.Left;
            int tgtHeight = gRect.Bottom - gRect.Top;


            // centering and sizing our maximum bounding box based on a 4:3 ratio
            Size aspectedSize = new Size(4, 3);
            Size tgtFormSize = new Size(tgtWidth, tgtHeight);
            Size maxFitSize = CalculateResizeToFit(aspectedSize, tgtFormSize);
            int leftOffset, topOffset;
            leftOffset = (tgtWidth - maxFitSize.Width) / 2;
            topOffset = (tgtHeight - maxFitSize.Height) / 2;


            // again for selection window, but only if it's currently active
            if (_f_SelectionIndicator)
            {
                tgtWinLeft = gRect.Left + leftOffset - 4;
                tgtWinTop = gRect.Top + topOffset - 4;
                tgtWinWidth = maxFitSize.Width + 8;
                tgtWinHeight = maxFitSize.Height + 8;
            }


            // rip tgt's image, inserting into a buffer, resized properly. :)
            bufferHdc = g.GetHdc();
            GDI32.SetStretchBltMode(bufferHdc, 3); // don't know why 3's best.. and FAST, wow.
            GDI32.StretchBlt(bufferHdc, 0, 0, 400, 300, tgtHdc, leftOffset, topOffset, maxFitSize.Width, maxFitSize.Height, GDI32.TernaryRasterOperations.SRCCOPY);


            // release the bufferBitmap so we can draw on it internally
            g.ReleaseHdc(bufferHdc);




            if (opts._f_ApplyTimeStamp)
            {
                // create our brush shit up here so it's ready for a fast-write to avoid flickering (I hope);
                SolidBrush sb = new SolidBrush(Color.FromArgb(127, 127, 127, 127));
                String dtString = DateTime.Now.ToString(@"ddd, MMM dd, yyyy - HH\:mm\:ss");
                dtString += " " + (captures + 1).ToString().PadLeft(2, '0') + " [" + Global.sTitle + "]";
                Font font = new Font("Lucida Console", 9f, FontStyle.Regular);
                SizeF sf = g.MeasureString(dtString, font);
                int lOffset = 400 - (int)sf.Width;
                // draw our rectangle and timestmap (including current frame 1-30)
                g.FillRectangle(sb, lOffset, 0, sf.Width, sf.Height);
                g.DrawString(dtString, font, Brushes.White, lOffset + 1, 1);
                sb.Dispose();
                dtString = null;
                font.Dispose();
            }


            #region setPicture;
            if (pictureBox1.InvokeRequired)
            {
                pictureBox1.Invoke(new MethodInvoker(
                delegate()
                {
                    if (pictureBox1.Image != null)
                    {
                        Image oldImg = pictureBox1.Image;
                        pictureBox1.Image = null;
                        oldImg.Dispose();
                    }
                    pictureBox1.Image = (Bitmap)_bmpBuffer.Clone();
                    pictureBox1.Update();
                }));
            }
            else
            {
                if (pictureBox1.Image != null)
                {
                    Image oldImg = pictureBox1.Image;
                    pictureBox1.Image = null;
                    oldImg.Dispose();
                }
                pictureBox1.Image = (Bitmap)_bmpBuffer.Clone();
                pictureBox1.Update();
            }
            #endregion setPicture;












            #region DISPOSE GDI Objects;
            {
                _bmpBuffer.Dispose();
                GDI32.DeleteDC((int)tgtHdc);
                GDI32.ReleaseDC(IntPtr.Zero, tgtHdc);
                g.Dispose();
                GDI32.DeleteObject((int)bufferHdc);
            }
            #endregion DISPOSE GDI Objects;




        }

combobox binding json values

$
0
0
Hello, I seem to be having an issue with, not knowing how to make a proper binding in WPF.
I have the combobox displaying the proper  DisplayName but on selection the value sent is not what is the text in the combo box selection

Here is my combobox

<se:MyComboBox x:Name="AssetLibrarySetName"
                           Grid.Row="0"
                           Grid.Column="1"
                           IsEditable="true"
                           ItemsSource="{Binding Path=DownloadablePackages}"
                           Text="{Binding Path=AssetLibrarySetName, UpdateSourceTrigger=PropertyChanged}">
                 <ComboBox.ItemTemplate>
                        <DataTemplate DataType="GameInfo:DownloadablePackageDefinition">
                                <Label Content="{Binding Path=DisplayName}"/>
                        </DataTemplate>
                </ComboBox.ItemTemplate>
</se:MyComboBox>



Here is the asset code on




public string AssetLibrarySetName
{
get
{
if (this.AssetLibrarySetId == 0)
{
return "Base Game";
}

var package = InfoManager.DownloadablePackages.Items
.Select(kv => kv.Value)
.FirstOrDefault(dp => dp.Id == this.AssetLibrarySetId);
if (package == null)
{
return string.Format("(unknown #{0})", this.AssetLibrarySetId);
}

return string.Format("{1} (#{0})",
this.AssetLibrarySetId,
package.DisplayName);
}

set
{
this.AssetLibrarySetName = value;
if (this.AssetLibrarySetName == "Base Game" )
{
this.AssetLibrarySetId = 0;
}
var package = InfoManager.DownloadablePackages.Items
.Select(kv => kv.Value)
.FirstOrDefault(dp => dp.DisplayName == this.AssetLibrarySetName);
if (package == null)
{
this.AssetLibrarySetId = 0;
}
else
{
this.AssetLibrarySetId = package.Id;
}
}
}

On click the Label Content="{Binding Path=DisplayName}" needs to be sent and its sending "GameInfo.DownloadablePackageDefinition"

what am I missing?

how to save the image as bytes in MVC 4 Razor application?

$
0
0
how to save the image as bytes in MVC 4 Razor application?

WCF Service call in JQyuery.

$
0
0
Hi frnds.

 Im using JQuery function to call WCF service , in JQuery 4.1 version working fine but i change JQuery version 8.1 means not working , pls give solution ,

Thanks in Advance..

jquery wcf call not working in firefox

$
0
0
Hi frnds.

1)  im working in WCF application , give me a sample application ,
2) jquery wcf call not working in firefox .

Pls give solution .


Scheduled Task Status & Email Notification Based on Status

$
0
0
Hi ,

Currently i do have a requirement to develop a console based windows application which will check the status of all scheduled jobs scheduled in windows task scheduler and based on the job status it will fire email .


Have scheduled few automated tasks in windows task scheduler.Now need to develop a new task which will read the status of all the scheduled task and based on the status(whether it ran in specified time or not,success or failed ) it should fire an auto alert email using C#.

Anyone have any idea on this please.

Would appreciate if i get any response from anyone.

Many Thanks,
Sisir

MVC Validation

$
0
0
Hi,
 
In My MVC application I need to remove error tool tips when a radio button is changed and here I have written the following method but it is not working,so what is the problem and please give me the solution

$(document).ready(function () { $("#charSchoolHaveStaffHouses").change(function () { if ("#charSchoolHaveStaffHouses".checked) { $("#intStaffHousesCount [data-val]").attr("data-val", true); $("#intStaffHousesCount ").show(); } else { $("#intStaffHousesCount [data-val]").attr("data-val", false); $("#intStaffHousesCount [data-val]").removeClass(); $('intStaffHousesCount.validation-summary-errors').removeClass('myStyle input-validation-error'); $('intStaffHousesCount.validation-summary-errors').removeClass('field-validation-error ui-state-error-icon ui-icon-alert'); //field-validation-error ui-state-error-icon ui-icon-alert // $("#intStaffHousesCount ").hide(); } }) });

In the above when changing the radio buttons the textbox should be disabled and needs to remove error providers



Thanks in advance



extract files from a ppf

$
0
0
Hi,

I would like to get all files from a ppf. 

Thanks 

Darma

how to solve hanging problem in sql query using vb 6.0.

$
0
0
hi friends,


       please help me about the hanging problem in SQL QUERY at the same record access multiple user. when same record allocate the multiple user then hang the machine for 5-6 seconds.





regards,

Hemant Chaudhary
9867765755

Entity Framework for MS Access

$
0
0
Hi All,

Can I create .edmx from MS Accss database ?

cannot able to convert ms access database to sqlserver

$
0
0
Hi friends
I have tried to convert ms access database to sql database.but i could not able to done it successfully. the below methods are i have been using so for
1.from sql server 2008 i created a empty database and try to import data from task but it shows
 cannot start your application.the workgroup information is missing or open by another user.(microsoft jet database engine).
2. i try to convert through ssma, it encounters problem in add database from ms access.the error is
Retrieving the COM class factory for component with CLSID {CD7791B9-43FD-42C5-AE42-8DD2811F0419} failed due to the following error: 80040154. This error may be a result of running SSMA as 64-bit application while having only 32-bit connectivity components installed or vice versa. You can run 32-bit SSMA application if you have 32-bit connectivity components or64-bit SSMA application if you have 64-bit connectivity components, shortcut to both 32-bit and64-bit SSMA can be found under the Programs menu. You can also consider updating your connectivity components from http://go.microsoft.com/fwlink/?LinkId=197502.      An error occurred while loading database content.
 
3. I have check my system whether it contain mdac.by typing i 
 Regsvr32.exe "<<Dao360.dll_Path>>"
it show this module fail to load.and could not be found.
 
My question is 
 
i am using windows 8 x64 processor. how can convert this ms access database to sql server database. please give me suitable answer. i tried with google in different manner.but i am not able to find the answer. please help me
 

Thanks in Advance

job

$
0
0
which one is best government or private in IT
Viewing all 32756 articles
Browse latest View live