|
Hi,
I need develop an quiz project using GridView Control .
I try to include question with RadioButtonList in single cell but i am unable to embeded RadioButtonList for GridView Control .kindly suggest me how to solve this problem.
Thanks,
Murugan k
|
|
|
|
|
Hi,
Try out like this:
<asp:GridView ID="GridViewContactOptions" runat="server"
AutoGenerateColumns="False" DataKeyNames="ID"
DataSourceID="AccessDataSourceContactOptions" Width="494px">
<Columns>
<asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False" ReadOnly="True" SortExpression="ID" />
<asp:BoundField DataField="AccountNo" HeaderText="AccountNo" SortExpression="AccountNo" />
<asp:BoundField DataField="Contact" HeaderText="Contact" SortExpression="Contact" />
<asp:TemplateField HeaderText="HN">
<ItemTemplate>
<asp:RadioButtonList AutoPostBack="true" ID="RadioButtonListHydraNotes" runat="server" Enabled="true"
RepeatDirection="Horizontal" TextAlign="Left" SelectedIndex='<%#Convert.ToInt32(DataBinder.Eval(Container.DataItem , "HydraNotes"))%>'
OnSelectedIndexChanged="rbl_SelectedIndexChanged">
<asp:ListItem Value="1">E</asp:ListItem>
<asp:ListItem Value="2">F</asp:ListItem>
<asp:ListItem Value="3">M</asp:ListItem>
</asp:RadioButtonList>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
|
|
|
|
|
this is my array syntax..
int[,] numbers = { { 1, 1 }, { 1, 2 }, { 1, 3 }, { 2, 4 }, { 2, 5 }, { 2, 6 }, { 2, 7 }, { 3, 8 }, { 1, 9 }, { 1, 10 }, { 2, 11 }, { 3, 12 }, { 2, 13 }, { 1, 14 }, { 1, 15 } };
now my question is
i want 2 delete frist element of 1's means delete {1,1},{1,2},{1,3},{1,9},{1,10},{1,14},{1,15}
my o/p should be like this :{2,4},{2,5},{2,6},{2,7},{3,8},{2.11},{3,12},{2,13}
please can u tell me how to do this ..
thanx in advance brothers..
Some Thing need 2 do NEW
modified on Tuesday, March 24, 2009 8:08 AM
|
|
|
|
|
int[,] numbers = {{2,4},{2,5},{2,6},{2,7},{3,8},{2,11},{3,12},{2,13}};
edit: sorry copied the wrong thing first
but now more serious, you probably have and array of small 2-length arrays and you want to remove the fist of all pairs and let the rest fill up the gaps Without knowing the array in advance. Otherwise it just doesn't make sense.
But that isn't too hard..
|
|
|
|
|
ok thns brother ,. i ll try with u r logic..
Some Thing need 2 do NEW
|
|
|
|
|
Ok yes let me help some more then, cause I didn't actually do anything to help yet
Anyway, what I would probably do, if it is sure that you number of elements will halve, create a new int[2,length/2] , scan through the old array and only use the correct places like:
int[,] result = new int[2,array.GetLength(0)/2];
for (int i = 0; i < array.GetLength(0); i++)
{
result[i&1,i/2] = array[1,i];
}
I hope that is what you mean?
edit: aah no it is not what you mean, but it's close..
Ok this is harder, since you don't know the size of the result yet..
maybe first put all elements that are not 1 into a List<int> and then turn that into an int[2,List.Count/2] ?
|
|
|
|
|
OK new code
List<int> temp = new List<int>;
foreach (int i in array)
temp.Add(i);
int[,] result = new int[2,tmp.Count/2];
for (int i = 0; i < temp.Count; i++)
result[i&1,i/2] = temp[i];
warning: untested
|
|
|
|
|
thnx dude..
Some Thing need 2 do NEW
|
|
|
|
|
ok yea don't use it though, I still messed up!
I'm really not in shape today
Ok, attempt #3
List<int[]> temp = new List<int[]>();
for (int i = 0; i < array.GetLength(1); i++)
{
if (array[0,i] != 1)
temp.Add(new int[] { array[0,i], array[1,i] });
}
int[,] result = new int[2,temp.Count];
for (int i = 0; i < temp.Count; i++)
{
result[0,i/2] = temp[i][0];
result[1,i/2] = temp[i][1];
}
Untested, but I think it should be alright..
|
|
|
|
|
Nope, try again
your second for loop will chuck an error when trying to access i/2 as your loop is incremnting by only 1
...well if it does work it will be the wrong index
...actually you may just get a 'divide by zero' error on first run
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
There is no opportunity to divide by zero
Ok maybe that divide by 2 makes no sense after all, it seemed like a good idea at the time
|
|
|
|
|
harold aptroot wrote: There is no opportunity to divide by zero
...my bad
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
thanx buddy..
Some Thing need 2 do NEW
|
|
|
|
|
What is it your trying to achieve? do you want to remove any array items that start with 1?
if so you just need to loop the original array and copy and items that do not start with a one to a new output array
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
thanx musefan ...
yes i want 2 remove start with 1 ..can u tell me do u have any code like kind of this probelm..
Some Thing need 2 do NEW
|
|
|
|
|
ok ill try give you a sample but im not sure if with compile but will hopefully give you an idea if it does not...
int[,] RemoveEntries(int[,] original, int numberToRemove)
{
System.Collections.ObjectModel.Collection<int> newVals = new System.Collections.ObjectModel.Collection<int>();
for(int i = 0; i < orignal.GetLength(0); i++)
{
if(original[i, 0] != numberToRemove)
{
newVals.Add(original[i, 0]);
newVals.Add(original[i, 1]);
}
}
int[,] result = new int[newVals.Length/2, 2];
int count = 0;
for(int i = 0; i < newVals.length; i+=2)
{
result[count, 0] = newVals[i];
result[count, 1] = newVals[i+1];
count++;
}
return result;
}</int></int>
Its prob not the most effecient way but I have not worked with 2D arrays in a while and thought it best to post something that has a better chance of working.
Hope this helps
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
I have a dataGridView whos datasource is a bindingSource.
When I recompile my solution all the bindingSource fields are added into the dataGridView again. How can I stop this please?
Oh, and AutoGenerateColumns is set to False
modified on Tuesday, March 24, 2009 8:32 AM
|
|
|
|
|
I am also facing the same problem. In my case I need to Hide the ID column but I am not able to do so .. .
Might be you need to write a small function to make changes after the initialize component.
|
|
|
|
|
Hello,
How we can open ftp and get data? thank you verry mutch.
|
|
|
|
|
|
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
timer1.Interval = 5000;
timer1.Enabled = true;
timer1.Start();
}
private void timer1_Tick(object sender, EventArgs e)
{
for (int i = 0; i < 5 ; i++)
{
pictureBox1.Image = imageList1.Images[i];
}
}
}
}
************************
every time i run this application only the last image from the image list is displayed. I need to display all d images with 5 seconds delay between each of them !!!
plz help needed !!!
where am i goin wrong >?????????????
|
|
|
|
|
your problem is in your tick event handler. you are looping all the images at once. to solve your problem you need to create a Global index for the image currently being displayed then increment that with every tick and display the appropriate image.
Do you understand?
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
thanks a lot it worked !!!
|
|
|
|
|
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication1
{
public partial class Form1 : Form
{
//Variables
int currentimageindex = 1;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
timer1.Interval = 5000;
timer1.Enabled = true;
timer1.Start();
}
private void timer1_Tick(object sender, EventArgs e)
{
if(currentimageindex <= 5)
{
pictureBox1.Image = imageList1.Images[currentimageindex];
currentimageindex++;
}
else
{
currentimageindex = 1;
}
}
}
}
}
|
|
|
|
|
I am trying to build a DLL that returns a number that increments by one each time it is called by any application - in such a way that if app A and app B are calling the DLL one after another you will see it jump by two in app A and app B. This is not like a normal DLL which is local to each app and has no memory in common. For this I think I need a Shared Assembly in the Global Assembly Cache.
Here is my DLL:
namespace willyhoops
{
// not threadsafe
public sealed class Willyhoops
{
private static Willyhoops instance = null;
int i;
private Willyhoops()
{
}
public static Willyhoops Instance
{
get
{
if (instance == null)
{
instance = new Willyhoops();
}
return instance;
}
}
public int TestFunction()
{
return ++i;
}
}
}
The idea here is a singleton so that every call to TestFunction will return a number that goes up no matter from which application it is called.
And I have got this DLL into the global assembley cache.
Here is my Console Application test:
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using willyhoops;
class Program
{
static void Main(string[] args)
{
App a = new App();
}
}
public class App
{
public App()
{
Willyhoops w = null;
w = Willyhoops.Instance;
while (true)
{
int i = w.TestFunction();
Console.WriteLine(i);
Thread.Sleep(1000);
}
}
}
And I went in project, add reference and pointed it at the willhoops.dll in the release directory from before.
But it does not work... Each time I launch a new app it starts again at zero just like a normal DLL that is local to each app...
I am stuck please can someone help!
It may be that I am barking up the wrong tree and this Shared Assembly method can not help.
I looked on the web for a long time and found just this:
Question: How to share memory between CLR calls to the same C# dll?
Answer: Are you doing this in the same app domain? If so, then a static member is all you need. However, if you want to do this in different application domains, then you can't use shared memory from C#. Rather, you would have to create a service (not a literal one, but one instance which other app domains communicate with) which will host the values and return them to the callers.
But that is too vague to be of much use and I have gone down this shared assembly route... Of course I could use a socket or even the registry or any number of hacks but how to do this properly. This is a common task (eg Drivers, ODBC etc) and must be possible in C#...
<div class="ForumMod">modified on Tuesday, March 24, 2009 6:59 AM</div>
|
|
|
|
|