473,396 Members | 1,766 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

2 gridview questions regarding manually populate

I have a gridview on the page that i want to dynamically populate with
radiobuttons, so i went out on the net and found something that works
perfectly, it created radionuttons and the postback with the works. My
problem is that i want to send 2 columns to the gridview instead of 1, but i
cant figure out how to add the second column to the gridview.
<asp:GridView ID="GridView1" AutoGenerateColumns="false" runat="server"
ShowHeader="false">
<Columns>
<asp:TemplateField HeaderText="Select">
<ItemTemplate>
<input type="radio" name="radiolist" value="<%# Container.DataItem%>" />
<------ Here i want the 2nd column that i dont know how to attach to the
gridview
</ItemTemplate>
< ----- Container.DataItem displays only one column,
what should i use instead? Eval something?
</asp:TemplateField>
<asp:TemplateField HeaderText="Data">
<ItemTemplate>
<%# Container.DataItem %<!-- here i want the first column to be displayed
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>

This is the code i use to get one column into the gridview, but how do i get
a second one? (the second one should just contain a list of number 0--number
of answers in the poll)
This is what i want to be added to the radiobox value
ArrayList mList = new ArrayList();
for (int i = 0; i < mRow.Length; i++)
{
mList.Add(i.ToString());
}
This is what i have now
DataTable mTable = LSQ.Labervote_GetPoll("1");
DataRow[] mRow = mTable.Select();
char[] charsep = new char[1];
charsep[0] = '|';
string[] datastring = mRow[0].ItemArray[1].ToString().Split(charsep,
StringSplitOptions.None);
GridView1.DataSource = datastring;
GridView1.DataBind();

Patrick

Feb 23 '07 #1
1 3865
What's your exact problem ?
1. Are you not able to display two columns in GridView with RadioButtons
2. Do you want to display Two Radio Buttons within the one column of the
Grid View
3. Do you want to display the text (bind from data source) along with
RadioButtons in each seperate column

Please let me know what exactly you are looking for ?
--
Thanks & Regards,
Sundar Narasiman
"Patrick F" wrote:
I have a gridview on the page that i want to dynamically populate with
radiobuttons, so i went out on the net and found something that works
perfectly, it created radionuttons and the postback with the works. My
problem is that i want to send 2 columns to the gridview instead of 1, but i
cant figure out how to add the second column to the gridview.
<asp:GridView ID="GridView1" AutoGenerateColumns="false" runat="server"
ShowHeader="false">
<Columns>
<asp:TemplateField HeaderText="Select">
<ItemTemplate>
<input type="radio" name="radiolist" value="<%# Container.DataItem%>" />
<------ Here i want the 2nd column that i dont know how to attach to the
gridview
</ItemTemplate>
< ----- Container.DataItem displays only one column,
what should i use instead? Eval something?
</asp:TemplateField>
<asp:TemplateField HeaderText="Data">
<ItemTemplate>
<%# Container.DataItem %<!-- here i want the first column to be displayed
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>

This is the code i use to get one column into the gridview, but how do i get
a second one? (the second one should just contain a list of number 0--number
of answers in the poll)
This is what i want to be added to the radiobox value
ArrayList mList = new ArrayList();
for (int i = 0; i < mRow.Length; i++)
{
mList.Add(i.ToString());
}
This is what i have now
DataTable mTable = LSQ.Labervote_GetPoll("1");
DataRow[] mRow = mTable.Select();
char[] charsep = new char[1];
charsep[0] = '|';
string[] datastring = mRow[0].ItemArray[1].ToString().Split(charsep,
StringSplitOptions.None);
GridView1.DataSource = datastring;
GridView1.DataBind();

Patrick
Feb 23 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: | last post by:
Hello, I am trying to get add a product to a cart from a gridview control when a button in the gridview is clicked. I have a book on how to do this in asp.net 2.0 but it is done by specifying...
7
by: | last post by:
Hello, Does anyone have an idea on how I can filter the data in the gridview control that was returned by an sql query? I have a gridview that works fine when I populate it with data. Now I...
5
by: Dick | last post by:
I have a GridView bound to an ObjectDataSource. I have a Button that calls GridView.DataBind. I want the row that is selected before the DataBind to still be selected afterwards. This happens...
5
by: Amit | last post by:
Hello, I have a simple search screen, with two drop-downs and a text box. There's also a GridView control that is using a SqlDataSource control to show the matching results. The SqlDataSource uses...
5
by: Diane Truyens | last post by:
Hi, I have a form with textboxes, a search button and a gridview. The textboxes are filled with default values so that the gridview should return all rows but not before the user has had the...
1
by: JasonK | last post by:
I would like to move the Delete button such that it displays one time in the footer row, rather than on every row. I've seen lots of questions asked on the subject around the net, but no answer...
0
by: =?Utf-8?B?TGFkaXNsYXYgTXJua2E=?= | last post by:
Hello, I read some msdn and other articles about how does databinding among DataSource controls and FormView / GridView controls works but I still don't fully understand to this blackbox. I have...
4
by: marksommerville | last post by:
I have a few questions regarding accessing a gridview control from Javascript which I would really appreciate some help with. 1. The gridview contains a column of checkboxes as a template field....
11
by: SAL | last post by:
Hello, I have a Gridview control (.net 2.0) that I'm having trouble getting the Update button to fire any kind of event or preforming the update. The datatable is based on a join so I don't know...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.