473,824 Members | 3,338 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

datagrid,spliti ng value from database

LU
VAR1 = 3/4
VAR2 = 2
I user can submit the values "3/4" or "2" (VAR1, VAR2 represent any numbers)
when user submits "3/4" we assume 1sthalf/2ndhalf
These values are saved into database as a row
row1: 3/4
row2: 2

I have a datagrid that displays values just fine, but user wants to beable
to click on the 3 or 4 when we have a "/" in the value.
How do I split the value when it finds a "/" ,
then create a button column(for an event) for each value. This would allow
the user to click the 3 "or" 4 in 3/4 and then i could run an event based on
what they clicked.
so,
I was thinking
<a href="p.aspx?id =1sthalf&value= 3">3</a> /
<a href="p.aspx?id =2ndhalff&value =4">4</a>
I don't know how to do something like this in the data grid and/or datalist.
If it doesn't find a "/" it should assume 1sthalf.
Any ideas, hints, HELP would be GREAT!

Nov 19 '05 #1
5 1294
string s = "3/4";
string[] parts = s.Split('/');
// use parts[0] and parts[1]

-Brock
DevelopMentor
http://staff.develop.com/ballen
VAR1 = 3/4
VAR2 = 2
I user can submit the values "3/4" or "2" (VAR1, VAR2 represent any
numbers)
when user submits "3/4" we assume 1sthalf/2ndhalf
These values are saved into database as a row
row1: 3/4
row2: 2
I have a datagrid that displays values just fine, but user wants to
beable
to click on the 3 or 4 when we have a "/" in the value.
How do I split the value when it finds a "/" ,
then create a button column(for an event) for each value. This would
allow
the user to click the 3 "or" 4 in 3/4 and then i could run an event
based on
what they clicked.
so,
I was thinking
<a href="p.aspx?id =1sthalf&value= 3">3</a> /
<a href="p.aspx?id =2ndhalff&value =4">4</a>
I don't know how to do something like this in the data grid and/or
datalist.
If it doesn't find a "/" it should assume 1sthalf.
Any ideas, hints, HELP would be GREAT!


Nov 19 '05 #2
LU
Yes, but how do I make that work inside the datagrid ?

"Brock Allen" wrote:
string s = "3/4";
string[] parts = s.Split('/');
// use parts[0] and parts[1]

-Brock
DevelopMentor
http://staff.develop.com/ballen
VAR1 = 3/4
VAR2 = 2
I user can submit the values "3/4" or "2" (VAR1, VAR2 represent any
numbers)
when user submits "3/4" we assume 1sthalf/2ndhalf
These values are saved into database as a row
row1: 3/4
row2: 2
I have a datagrid that displays values just fine, but user wants to
beable
to click on the 3 or 4 when we have a "/" in the value.
How do I split the value when it finds a "/" ,
then create a button column(for an event) for each value. This would
allow
the user to click the 3 "or" 4 in 3/4 and then i could run an event
based on
what they clicked.
so,
I was thinking
<a href="p.aspx?id =1sthalf&value= 3">3</a> /
<a href="p.aspx?id =2ndhalff&value =4">4</a>
I don't know how to do something like this in the data grid and/or
datalist.
If it doesn't find a "/" it should assume 1sthalf.
Any ideas, hints, HELP would be GREAT!


Nov 19 '05 #3
<ItemTemplate >
<asp:Button runat=server CommandName="My Button" CommandArgument ='<%# GetLeftHalf(Con tainer.DataItem )
%>' Text="LeftHalf" />
<asp:Button runat=server CommandName="My Button" CommandArgument ='<%# GetRightHalf(Co ntainer.DataIte m)
%>' Text="RightHalf " />
</ItemTemplate>

Where GetLeftHalf:

string GetLeftHalf(obj ect data)
{
string s= (string)data;
return s.Split('/')[0]; // do better error checking that i am here :)
}

Then to handle the click handle the DataGrid's ItemCommand event:

void Grid_ItemComman d(object s, DataGridCommand EventArgs e)
{
if (e.CommandName == "MyButton")
{
string theNumber = e.CommandArgume nt;
/// and so on...
}
}

This is very rough as it's off the top of my head, but I think it should
get you started in the right direction.

-Brock
DevelopMentor
http://staff.develop.com/ballen
Yes, but how do I make that work inside the datagrid ?

"Brock Allen" wrote:
string s = "3/4";
string[] parts = s.Split('/');
// use parts[0] and parts[1]
-Brock
DevelopMentor
http://staff.develop.com/ballen
VAR1 = 3/4
VAR2 = 2
I user can submit the values "3/4" or "2" (VAR1, VAR2 represent any
numbers)
when user submits "3/4" we assume 1sthalf/2ndhalf
These values are saved into database as a row
row1: 3/4
row2: 2
I have a datagrid that displays values just fine, but user wants to
beable
to click on the 3 or 4 when we have a "/" in the value.
How do I split the value when it finds a "/" ,
then create a button column(for an event) for each value. This
would
allow
the user to click the 3 "or" 4 in 3/4 and then i could run an event
based on
what they clicked.
so,
I was thinking
<a href="p.aspx?id =1sthalf&value= 3">3</a> /
<a href="p.aspx?id =2ndhalff&value =4">4</a>
I don't know how to do something like this in the data grid and/or
datalist.
If it doesn't find a "/" it should assume 1sthalf.
Any ideas, hints, HELP would be GREAT!


Nov 19 '05 #4
LU
This works, but it how do I remove one of them when it only has 1 number and
not 2?
so If i have 3/4 it works, but what about if I have 1 or 10
It seems I will have an extra button.
"Brock Allen" wrote:
<ItemTemplate >
<asp:Button runat=server CommandName="My Button" CommandArgument ='<%# GetLeftHalf(Con tainer.DataItem )
%>' Text="LeftHalf" />
<asp:Button runat=server CommandName="My Button" CommandArgument ='<%# GetRightHalf(Co ntainer.DataIte m)
%>' Text="RightHalf " />
</ItemTemplate>

Where GetLeftHalf:

string GetLeftHalf(obj ect data)
{
string s= (string)data;
return s.Split('/')[0]; // do better error checking that i am here :)
}

Then to handle the click handle the DataGrid's ItemCommand event:

void Grid_ItemComman d(object s, DataGridCommand EventArgs e)
{
if (e.CommandName == "MyButton")
{
string theNumber = e.CommandArgume nt;
/// and so on...
}
}

This is very rough as it's off the top of my head, but I think it should
get you started in the right direction.

-Brock
DevelopMentor
http://staff.develop.com/ballen
Yes, but how do I make that work inside the datagrid ?

"Brock Allen" wrote:
string s = "3/4";
string[] parts = s.Split('/');
// use parts[0] and parts[1]
-Brock
DevelopMentor
http://staff.develop.com/ballen
VAR1 = 3/4
VAR2 = 2
I user can submit the values "3/4" or "2" (VAR1, VAR2 represent any
numbers)
when user submits "3/4" we assume 1sthalf/2ndhalf
These values are saved into database as a row
row1: 3/4
row2: 2
I have a datagrid that displays values just fine, but user wants to
beable
to click on the 3 or 4 when we have a "/" in the value.
How do I split the value when it finds a "/" ,
then create a button column(for an event) for each value. This
would
allow
the user to click the 3 "or" 4 in 3/4 and then i could run an event
based on
what they clicked.
so,
I was thinking
<a href="p.aspx?id =1sthalf&value= 3">3</a> /
<a href="p.aspx?id =2ndhalff&value =4">4</a>
I don't know how to do something like this in the data grid and/or
datalist.
If it doesn't find a "/" it should assume 1sthalf.
Any ideas, hints, HELP would be GREAT!


Nov 19 '05 #5
You can always add/remove items to the row in the ItemDataBound event of
the grid. In that even you have access to DataGridItemEve ntArgs.Item so you
can add new controls to use FindContorl to remove or hide existing controls.

-Brock
DevelopMentor
http://staff.develop.com/ballen
This works, but it how do I remove one of them when it only has 1
number and
not 2?
so If i have 3/4 it works, but what about if I have 1 or 10
It seems I will have an extra button.
"Brock Allen" wrote:
<ItemTemplate >

<asp:Button runat=server CommandName="My Button" CommandArgument ='<%#
GetLeftHalf(Con tainer.DataItem )

%>' Text="LeftHalf" />

<asp:Button runat=server CommandName="My Button" CommandArgument ='<%#
GetRightHalf(Co ntainer.DataIte m)

%>' Text="RightHalf " />

</ItemTemplate>

Where GetLeftHalf:

string GetLeftHalf(obj ect data)
{
string s= (string)data;
return s.Split('/')[0]; // do better error checking that i am here :)
}
Then to handle the click handle the DataGrid's ItemCommand event:

void Grid_ItemComman d(object s, DataGridCommand EventArgs e)
{
if (e.CommandName == "MyButton")
{
string theNumber = e.CommandArgume nt;
/// and so on...
}
}
This is very rough as it's off the top of my head, but I think it
should get you started in the right direction.

-Brock
DevelopMentor
http://staff.develop.com/ballen
Yes, but how do I make that work inside the datagrid ?

"Brock Allen" wrote:

string s = "3/4";
string[] parts = s.Split('/');
// use parts[0] and parts[1]
-Brock
DevelopMentor
http://staff.develop.com/ballen
> VAR1 = 3/4
> VAR2 = 2
> I user can submit the values "3/4" or "2" (VAR1, VAR2 represent
> any
> numbers)
> when user submits "3/4" we assume 1sthalf/2ndhalf
> These values are saved into database as a row
> row1: 3/4
> row2: 2
> I have a datagrid that displays values just fine, but user wants
> to
> beable
> to click on the 3 or 4 when we have a "/" in the value.
> How do I split the value when it finds a "/" ,
> then create a button column(for an event) for each value. This
> would
> allow
> the user to click the 3 "or" 4 in 3/4 and then i could run an
> event
> based on
> what they clicked.
> so,
> I was thinking
> <a href="p.aspx?id =1sthalf&value= 3">3</a> /
> <a href="p.aspx?id =2ndhalff&value =4">4</a>
> I don't know how to do something like this in the data grid and/or
> datalist.
> If it doesn't find a "/" it should assume 1sthalf.
> Any ideas, hints, HELP would be GREAT!


Nov 19 '05 #6

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

Similar topics

0
2003
by: Gamze | last post by:
Hi, How can i get values from datagrid to combobox and should select the same name as in datagrid row on the combobox control In my vb.net windows application ,i have combobox which is populated by sqlserver database table.When i select value from combobox ,value saved in to other table of my database and i use to datagrid to show this table.
9
1550
by: Sreejith S S Nair | last post by:
hi there, I have a panel control which contain more than 10 label controls. these label controls are added dynamically by user. In this application user can slit a control into not less than 10 different shares. (don't worry about this. If a user select a control to split into 5 or 10. i am simply creating 5 or 10 controls which have the size 5/10 or 10/10 of the
0
1337
by: Sreejith S S Nair | last post by:
hi, Setp one. i have one panel control in my form. I am spliting this panel control into two part say working region and holding region. This spliting is only logic spliting. That is i am dividing(logically spliting) panels few portion (region) for
5
2602
by: Jeff | last post by:
IDE: VS 2003 :NET OS: XP Pro My app have a form with a tab-control on it. The tab-control have 2 tabpages. One of the tabpages displays a datagrid, and the other tabpage displays details (order date, name, address etc) about the selected row in the datagrid... My problem is when I enter a new record in the details tabpage (saves data to database), and go back to the datagrid. Only the data from the PM-table
3
4889
by: Jim Heavey | last post by:
Trying to figure out the technique which should be used to add rows to a datagrid. I am thinking that I would want an "Add" button on the footer, but I am not quite sure how to do that. Is that the best method? Do you have a sample of how to do this?
5
2045
by: junglist | last post by:
Hi guys, I've been trying to implement an editable datagrid and i have been succesful up to the point where i can update my datagrid row by row. However what used to happen was that once i updated one row, all of them were updated so i immediatelly figured out that i have to include the id of every entry in the update statement. This is where the problem is raised. My database is an Access database. The table i am updating contains a Date...
13
2679
by: Lyners | last post by:
I have a web page writen in ASP.NET that contains some javascript so that when a user presses a button, or edits a certain field in a datagrid, another cell in the datagrid is filled with a value. My probelm.... when I have the user press the update button (which does a post back that loops through the datagrid and updates a database) the field/cell that is filled by the javascript appears to be blank in my update code, even though I can...
1
4240
by: sianan | last post by:
I tried to use the following example, to add a checkbox column to a DataGrid in an ASP.NET application: http://www.codeproject.com/aspnet/datagridcheckbox.asp For some reason, I simply CAN'T get the example to work. I created the following two classes, provided with the example: *-*-**-*-*-*-*-*-*-*-*-*-**-*-*-*-*-CheckBoxColumn Class:-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-**-*-*-*
0
2918
by: cindy | last post by:
I have a dynamic datagrid. I have custom classes for the controls public class CreateEditItemTemplateDDL : ITemplate { DataTable dtBind; string strddlName; string strSelectedID; string strDataValueField; string strDataTextField; public CreateEditItemTemplateDDL(string DDLName,string DataValueField,string
0
9631
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10736
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10496
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10182
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9285
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6933
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5601
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4398
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3064
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.